From d2668332d882566d1183839397b09f78d4b24153 Mon Sep 17 00:00:00 2001 From: Andrew Cutler Date: Mon, 1 Aug 2022 12:06:13 +1000 Subject: [PATCH] Add multiarch image build workflow --- .../dockerhub-build-push-multi-arch.yml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/dockerhub-build-push-multi-arch.yml diff --git a/.github/workflows/dockerhub-build-push-multi-arch.yml b/.github/workflows/dockerhub-build-push-multi-arch.yml new file mode 100644 index 0000000..b811695 --- /dev/null +++ b/.github/workflows/dockerhub-build-push-multi-arch.yml @@ -0,0 +1,69 @@ +# Source: https://github.com/panubo/reference-github-actions/blob/main/dockerhub-build-push-multi-arch.yml +# Description: Multi arch build and push to Docker Hub +# LICENSE: MIT License, Copyright (c) 2022 Volt Grid Pty Ltd t/a Panubo + +# - Multi arch build, amd64 and arm64 +# - Uses docker/metadata-action to generate image tags +# - Push to dockerhub + +name: Docker Hub Build and Push (Multi-arch) + +env: + REPO_NAME: docker.io/panubo/sshd + +on: + push: + branches: + - main + tags: + - 'v*' + +jobs: + build_and_push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + # list of Docker images to use as base name for tags + images: | + ${{ env.REPO_NAME }} + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.PANUBUILD_DOCKERHUB_USERNAME }} + password: ${{ secrets.PANUBUILD_DOCKERHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v3 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: Dockerfile + push: ${{ github.event_name != 'pull_request' }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}