Skip to content

Commit

Permalink
add permissions for token
Browse files Browse the repository at this point in the history
Signed-off-by: Sarath Chandra Oruganti <[email protected]>
  • Loading branch information
sarathchandra24 committed Mar 8, 2024
1 parent 897631d commit a2129df
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions .github/workflows/clone-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ on:
- personal-*
env:
DOCKER_REPO: "sarathchandra24"
DOCKER_IMAGE: "fluent-bit"
DOCKER_IMAGE: "fluent-operator"
GITHUB_IMAGE: "${{ github.repository }}/fluent-operator"

permissions:
contents: read
packages: write

jobs:
copy_images:
runs-on: ubuntu-latest
Expand All @@ -30,13 +34,35 @@ jobs:
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: docker metadata
id: release-metadata
uses: docker/metadata-action@v5
with:
tags: |
raw,latest
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Install Skopeo
run: sudo apt-get update && sudo apt-get install -y skopeo

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: display tags
run: echo "${{ steps.release-metadata.outputs.tags }}"

- name: Build and Push Image for Fluent Bit
id: docker-build
Expand All @@ -59,14 +85,14 @@ jobs:
DEST_CREDS="username:password"
# Get the list of tags from metadata action output
TAGS=$(echo "${{ steps.image-metadata.outputs.tags }}")
TAGS=$(echo "${{ steps.release-metadata.outputs.tags }}")
# Convert the string of tags to an array
IFS=',' read -ra TAGS_ARRAY <<< "$TAGS"
# Loop through each tag and copy the image
for tag in "${TAGS_ARRAY[@]}"; do
skopeo copy --src-creds=$SOURCE_IMAGE --dest-creds=$RELEASE_CREDS \
skopeo copy --src-creds=$SOURCE_CREDS --dest-creds=$RELEASE_CREDS \
"docker://$SOURCE_IMAGE:$tag" \
"docker://$RELEASE_IMAGE:$tag"
done
Expand Down

0 comments on commit a2129df

Please sign in to comment.