Skip to content

Commit

Permalink
fix: fixing Multi-platform image with GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sadok-f committed Feb 25, 2024
1 parent 2ab0d07 commit ce62db0
Showing 1 changed file with 64 additions and 3 deletions.
67 changes: 64 additions & 3 deletions .github/workflows/cd.yml
Expand Up @@ -4,6 +4,11 @@ on:
push:
branches:
- main

env:
REGISTRY_IMAGE: user/app


jobs:
release:
name: Create new Tag and Release
Expand Down Expand Up @@ -62,6 +67,12 @@ jobs:
- name: Code Checkout
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}:${{ needs.release.outputs.new_tag_version }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -82,9 +93,59 @@ jobs:
context: .
platforms: ${{ matrix.platform }}
file: ./Dockerfile
tags: |
flyimg/flyimg-build:latest
flyimg/flyimg-build:${{ needs.release.outputs.new_tag_version }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }}:${{ needs.release.outputs.new_tag_version }},push-by-digest=true,name-canonical=true,push=true
-
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
-
name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- docker_publish
steps:
-
name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}:${{ needs.release.outputs.new_tag_version }}
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}:${{ needs.release.outputs.new_tag_version }}@sha256:%s ' *)
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
deploy_demo:
name: Deploy to Demo demo.flyimg.io
Expand Down

0 comments on commit ce62db0

Please sign in to comment.