Skip to content

push tags

push tags #12

Workflow file for this run

name: Copy Docker Images
on:
push:
branches:
- main
- personal-*
env:
DOCKER_REPO: "sarathchandra24"
DOCKER_IMAGE: "fluent-operator"
GITHUB_IMAGE: "${{ github.repository }}/fluent-operator"
permissions:
contents: read
packages: write
jobs:
copy_images_metadata:
runs-on: ubuntu-latest
outputs:
image_tags: ${{ steps.release-metadata.outputs.tags }}
image_labels: ${{ steps.release-metadata.outputs.labels }}
docker_image_name: ${{ env.DOCKER_IMAGE }}
docker_image_repo: ${{ env.DOCKER_REPO }}
github_image: ${{ env.GITHUB_IMAGE }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: docker metadata
id: image-metadata
uses: docker/metadata-action@v5
with:
images: "ghcr.io/${{ env.GITHUB_IMAGE }}"
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: 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
uses: docker/build-push-action@v5
with:
context: .
file: ./cmd/fluent-manager/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }}
- name: Copy images
run: |
# Get the list of tags from metadata action output
TAGS=$(echo "${{ steps.release-metadata.outputs.tags }}")
# Loop through each tag and copy the image
echo "Total tags: $TAGS"
echo "$TAGS"
echo "$TAGS" | while IFS= read -r tag; do
echo "Copying $tag"
docker run --rm \
quay.io/skopeo/stable:latest \
copy \
--all \
--retry-times 10 \
--dest-creds "$RELEASE_CREDS" \
--src-creds "$SOURCE_CREDS" \
"docker://$SOURCE_IMAGE:$tag" \
"docker://$RELEASE_IMAGE:$tag"
done
env:
SOURCE_IMAGE: "ghcr.io/${{env.GITHUB_IMAGE}}"
RELEASE_IMAGE: "docker.io/${{env.DOCKER_REPO}}/${{ env.DOCKER_IMAGE }}"
RELEASE_CREDS: "${{ secrets.REGISTRY_USER }}:${{ secrets.REGISTRY_PASSWORD}}"
SOURCE_CREDS: "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}"