From 5b22c681c61184a464ffd7bbe790d517176c5ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Mon, 16 Feb 2026 00:38:02 +0100 Subject: [PATCH 1/2] Add arm64 platform to docker image --- .github/workflows/main.yml | 90 ++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d1ab9d2..aea2848 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,13 +32,21 @@ jobs: mix test.all docker: - name: Docker - runs-on: ubuntu-24.04 + name: Docker (${{ matrix.platform }}) + runs-on: ${{ matrix.runner }} permissions: contents: "read" id-token: "write" + strategy: + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-24.04 + - platform: linux/arm64 + runner: ubuntu-24.04-arm + env: IMAGE_NAME: "hexdocs" PROJECT_ID: "hexpm-prod" @@ -48,12 +56,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set short git commit SHA - id: vars - run: | - calculatedSha=$(git rev-parse --short ${{ github.sha }}) - echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -76,10 +78,72 @@ jobs: username: "oauth2accesstoken" password: "${{ steps.auth.outputs.access_token }}" - - name: Build and push + - name: Build and push by digest + id: build uses: docker/build-push-action@v6 with: - tags: gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHORT_SHA }} - push: ${{ github.event_name != 'pull_request' }} - cache-from: type=gha - cache-to: type=gha,mode=max + platforms: ${{ matrix.platform }} + outputs: type=image,name=gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} + cache-from: type=gha,scope=${{ matrix.platform }} + cache-to: type=gha,scope=${{ matrix.platform }},mode=max + + - name: Export digest + if: ${{ github.event_name != 'pull_request' }} + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + if: ${{ github.event_name != 'pull_request' }} + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.runner }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + docker-merge: + name: Docker Merge + runs-on: ubuntu-24.04 + if: ${{ github.event_name != 'pull_request' }} + needs: docker + permissions: + contents: "read" + id-token: "write" + env: + IMAGE_NAME: "hexdocs" + PROJECT_ID: "hexpm-prod" + SERVICE_ACCOUNT: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }} + WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCLOUD_WORKFLOW_IDENTITY_POOL_PROVIDER }} + steps: + - name: Set short git commit SHA + run: echo "COMMIT_SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV + - 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: Google auth + id: auth + uses: "google-github-actions/auth@v2" + with: + token_format: "access_token" + project_id: ${{ env.PROJECT_ID }} + service_account: ${{ env.SERVICE_ACCOUNT }} + workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} + - name: Docker Auth + uses: "docker/login-action@v3" + with: + registry: gcr.io + username: "oauth2accesstoken" + password: "${{ steps.auth.outputs.access_token }}" + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + -t gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHORT_SHA }} \ + $(printf 'gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) From ead89f77394f384fbf3a8cf1700f32f7284107fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Meadows-J=C3=B6nsson?= Date: Mon, 16 Feb 2026 00:50:46 +0100 Subject: [PATCH 2/2] Fix GHA cache scope containing slash --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aea2848..4b6275d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,8 +84,8 @@ jobs: with: platforms: ${{ matrix.platform }} outputs: type=image,name=gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} - cache-from: type=gha,scope=${{ matrix.platform }} - cache-to: type=gha,scope=${{ matrix.platform }},mode=max + cache-from: type=gha,scope=${{ matrix.runner }} + cache-to: type=gha,scope=${{ matrix.runner }},mode=max - name: Export digest if: ${{ github.event_name != 'pull_request' }}