Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

Commit a768041

Browse files
committed
Add arm64 platform to docker image
1 parent 8d69f9e commit a768041

1 file changed

Lines changed: 74 additions & 12 deletions

File tree

.github/workflows/main.yml

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,25 @@ jobs:
2323
- run: mix deps.unlock --check-unused
2424

2525
docker:
26-
name: Docker
27-
runs-on: ubuntu-24.04
26+
name: Docker (${{ matrix.platform }})
27+
runs-on: ${{ matrix.runner }}
2828
permissions:
2929
contents: "read"
3030
id-token: "write"
31+
strategy:
32+
matrix:
33+
include:
34+
- platform: linux/amd64
35+
runner: ubuntu-24.04
36+
- platform: linux/arm64
37+
runner: ubuntu-24.04-arm
3138
env:
3239
IMAGE_NAME: "preview"
3340
PROJECT_ID: "hexpm-prod"
3441
SERVICE_ACCOUNT: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }}
3542
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCLOUD_WORKFLOW_IDENTITY_POOL_PROVIDER }}
3643
steps:
3744
- uses: actions/checkout@v4
38-
- name: Set short git commit SHA
39-
id: vars
40-
run: |
41-
calculatedSha=$(git rev-parse --short ${{ github.sha }})
42-
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
4345
- name: Set up Docker Buildx
4446
uses: docker/setup-buildx-action@v3
4547
- name: Google auth
@@ -59,10 +61,70 @@ jobs:
5961
registry: gcr.io
6062
username: "oauth2accesstoken"
6163
password: "${{ steps.auth.outputs.access_token }}"
62-
- name: Build and push
64+
- name: Build and push by digest
65+
id: build
6366
uses: docker/build-push-action@v6
6467
with:
65-
tags: gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHORT_SHA }}
66-
push: ${{ github.event_name != 'pull_request' }}
67-
cache-from: type=gha
68-
cache-to: type=gha,mode=max
68+
platforms: ${{ matrix.platform }}
69+
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' }}
70+
cache-from: type=gha,scope=${{ matrix.platform }}
71+
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
72+
- name: Export digest
73+
if: ${{ github.event_name != 'pull_request' }}
74+
run: |
75+
mkdir -p /tmp/digests
76+
digest="${{ steps.build.outputs.digest }}"
77+
touch "/tmp/digests/${digest#sha256:}"
78+
- name: Upload digest
79+
if: ${{ github.event_name != 'pull_request' }}
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: digests-${{ matrix.runner }}
83+
path: /tmp/digests/*
84+
if-no-files-found: error
85+
retention-days: 1
86+
87+
docker-merge:
88+
name: Docker Merge
89+
runs-on: ubuntu-24.04
90+
if: ${{ github.event_name != 'pull_request' }}
91+
needs: docker
92+
permissions:
93+
contents: "read"
94+
id-token: "write"
95+
env:
96+
IMAGE_NAME: "preview"
97+
PROJECT_ID: "hexpm-prod"
98+
SERVICE_ACCOUNT: ${{ secrets.GCLOUD_SERVICE_ACCOUNT }}
99+
WORKLOAD_IDENTITY_PROVIDER: ${{ secrets.GCLOUD_WORKFLOW_IDENTITY_POOL_PROVIDER }}
100+
steps:
101+
- name: Set short git commit SHA
102+
run: echo "COMMIT_SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
103+
- name: Download digests
104+
uses: actions/download-artifact@v4
105+
with:
106+
path: /tmp/digests
107+
pattern: digests-*
108+
merge-multiple: true
109+
- name: Set up Docker Buildx
110+
uses: docker/setup-buildx-action@v3
111+
- name: Google auth
112+
id: auth
113+
uses: "google-github-actions/auth@v2"
114+
with:
115+
token_format: "access_token"
116+
project_id: ${{ env.PROJECT_ID }}
117+
service_account: ${{ env.SERVICE_ACCOUNT }}
118+
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
119+
- name: Docker Auth
120+
uses: "docker/login-action@v3"
121+
with:
122+
registry: gcr.io
123+
username: "oauth2accesstoken"
124+
password: "${{ steps.auth.outputs.access_token }}"
125+
- name: Create manifest list and push
126+
working-directory: /tmp/digests
127+
run: |
128+
docker buildx imagetools create \
129+
-t gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHORT_SHA }} \
130+
$(printf 'gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)

0 commit comments

Comments
 (0)