Skip to content

Commit

Permalink
docker ci
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Aug 19, 2024
1 parent e2b8444 commit c11c639
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Docker

# on:
# push:
# branches: [main, release/**]
# pull_request:
# release:
# types: [published]
on:
push:
branches: [main, release/**]
pull_request:
release:
types: [published]

concurrency:
group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
platform: linux/amd64
- runs-on: ubuntu-jammy-16-cores-arm64
platform: linux/arm64
runs-on: ubuntu-latest
runs-on: ${{ matrix.runs-on }}
steps:
- name: Prepare
run: |
Expand All @@ -50,33 +50,46 @@ jobs:
with:
images: ${{ env.REGISTRY_IMAGE }}

# QEMU is needed if building arm64 on amd64, but it is commented because the
# build is currently configured to build each natively.
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3

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

- name: Build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/myimage.tar

- name: Login to Docker Hub
if: github.event_name == 'release' && github.event.action == 'published'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push by digest
id: build
- name: Push by digest
if: github.event_name == 'release' && github.event.action == 'published'
id: push
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
if: github.event_name == 'release' && github.event.action == 'published'
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
digest="${{ steps.push.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
if: github.event_name == 'release' && github.event.action == 'published'
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
Expand All @@ -85,9 +98,9 @@ jobs:
retention-days: 1

merge:
if: github.event_name == 'release' && github.event.action == 'published'
needs: [build]
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
Expand All @@ -108,7 +121,7 @@ jobs:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create manifest list and push
Expand Down

0 comments on commit c11c639

Please sign in to comment.