Skip to content

Commit

Permalink
Update build and push workflow to include digest
Browse files Browse the repository at this point in the history
and manifest list creation
  • Loading branch information
n4ze3m committed Nov 18, 2023
1 parent bbf5ea6 commit a554139
Showing 1 changed file with 63 additions and 7 deletions.
70 changes: 63 additions & 7 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,27 @@ on:
push:
branches: [ next ]

env:
REGISTRY_IMAGE: n4z3m/dialoqbase-next

jobs:
docker:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: type=sha,prefix=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
Expand All @@ -18,13 +33,54 @@ jobs:
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}
- name: Build and push
password: ${{ secrets.DOCKERHUB_PWD }}
- name: Build and push by digest
id: docker_build
uses: docker/build-push-action@v5
with:
tags: |
n4z3m/dialoqbase-next:latest
platforms: ${{ matrix.platform }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max

- name: Export digest
run: |
echo "${{ steps.docker_build.outputs.digest }}" > digest.txt
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: digest.txt
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
- 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 }}
tags: type=semver,pattern={{version}}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}
- name: Create manifest list and push
run: |
while IFS= read -r digest; do
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:latest ${{ env.REGISTRY_IMAGE }}@${digest}
done < digests
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest

0 comments on commit a554139

Please sign in to comment.