Skip to content

Commit e2b5090

Browse files
committed
[ci] build arm64 images on arm64 runners
1 parent fbc99c7 commit e2b5090

File tree

1 file changed

+99
-20
lines changed

1 file changed

+99
-20
lines changed

.github/workflows/ci.yml

Lines changed: 99 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,31 @@ jobs:
3939
webhook: ${{ secrets.DISCORD_WEBHOOK }}
4040

4141
build:
42-
runs-on: ubuntu-latest
42+
runs-on: ${{ matrix.config.gh_image }}
4343
permissions:
4444
contents: read
4545
packages: write
4646
# This is used to complete the identity challenge
4747
# with sigstore/fulcio when running outside of PRs.
4848
id-token: write
4949

50+
strategy:
51+
matrix:
52+
config:
53+
- gh_image: ubuntu-latest
54+
arch: x86_64
55+
- gh_image: ubuntu-24.04-arm
56+
arch: aarch64
57+
5058
steps:
5159
- name: Checkout repository
5260
uses: actions/checkout@v4
5361

5462
# Install the cosign tool except on PR
5563
# https://github.com/sigstore/cosign-installer
56-
- name: Install cosign
57-
if: (github.event_name != 'pull_request') && !startsWith(github.ref, 'refs/heads/renovate')
58-
uses: sigstore/cosign-installer@v3
59-
60-
- name: Set up QEMU
61-
uses: docker/setup-qemu-action@v3
64+
# - name: Install cosign
65+
# if: (github.event_name != 'pull_request') && !startsWith(github.ref, 'refs/heads/renovate')
66+
# uses: sigstore/cosign-installer@v3
6267

6368
- name: Setup Docker buildx
6469
uses: docker/setup-buildx-action@v3
@@ -94,27 +99,100 @@ jobs:
9499
uses: docker/build-push-action@v6
95100
with:
96101
context: .
97-
platforms: linux/amd64,linux/arm64
98-
push: ${{ (github.event_name != 'pull_request') && !startsWith(github.ref, 'refs/heads/renovate') }}
99-
tags: ${{ steps.meta.outputs.tags }}
102+
tags: ${{ matrix.config.arch }}
100103
labels: ${{ steps.meta.outputs.labels }}
104+
outputs: type=docker,dest=${{ runner.temp }}/${{ matrix.config.arch }}.tar
101105
cache-from: type=gha
102106
cache-to: type=gha,mode=max
103107

108+
- name: Upload artifact
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: ${{ matrix.config.arch }}.tar
112+
path: ${{ runner.temp }}/${{ matrix.config.arch }}.tar
113+
104114
# Sign the resulting Docker image digest except on PRs.
105115
# This will only write to the public Rekor transparency log when the Docker
106116
# repository is public to avoid leaking data. If you would like to publish
107117
# transparency data even for private images, pass --force to cosign below.
108118
# https://github.com/sigstore/cosign
109-
- name: Sign the published Docker image
110-
if: ${{ (github.event_name != 'pull_request') && !startsWith(github.ref, 'refs/heads/renovate') }}
111-
env:
112-
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
113-
TAGS: ${{ steps.meta.outputs.tags }}
114-
DIGEST: ${{ steps.build-and-push.outputs.digest }}
115-
# This step uses the identity token to provision an ephemeral certificate
116-
# against the sigstore community Fulcio instance.
117-
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
119+
# - name: Sign the published Docker image
120+
# env:
121+
# # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
122+
# TAGS: ${{ steps.meta.outputs.tags }}
123+
# DIGEST: ${{ steps.build-and-push.outputs.digest }}
124+
# # This step uses the identity token to provision an ephemeral certificate
125+
# # against the sigstore community Fulcio instance.
126+
# run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
127+
128+
- uses: sarisia/actions-status-discord@v1
129+
if: failure()
130+
with:
131+
webhook: ${{ secrets.DISCORD_WEBHOOK }}
132+
133+
publish_manifest:
134+
runs-on: ubuntu-latest
135+
136+
# don’t run on PR or renovate commit
137+
if: (github.event_name != 'pull_request') && !startsWith(github.ref, 'refs/heads/renovate')
138+
needs:
139+
- build
140+
141+
steps:
142+
143+
- uses: actions/checkout@v4
144+
145+
- name: Podman login
146+
uses: redhat-actions/podman-login@v1
147+
with:
148+
registry: ${{ env.REGISTRY }}
149+
username: ${{ github.actor }}
150+
password: ${{ secrets.GITHUB_TOKEN }}
151+
152+
# Extract metadata (tags, labels) for Docker
153+
# https://github.com/docker/metadata-action
154+
- name: Extract Docker metadata
155+
id: meta
156+
uses: docker/metadata-action@v5
157+
with:
158+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
159+
tags: |
160+
type=schedule
161+
type=ref,event=branch
162+
type=ref,event=tag
163+
type=ref,event=pr
164+
type=sha
165+
166+
- name: Download artifact
167+
uses: actions/download-artifact@v4
168+
with:
169+
pattern: "*.tar"
170+
path: ${{ runner.temp }}
171+
merge-multiple: true
172+
173+
- name: push manifest
174+
run: |
175+
image_base_raw=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
176+
image_base=${image_base_raw@L}
177+
image_base_sha=${image_base}:${{ github.sha }}
178+
manifest=nanapi
179+
180+
podman manifest create ${manifest}
181+
182+
archs="x86_64 aarch64"
183+
184+
for arch in ${archs}; do
185+
podman load --input ${{ runner.temp }}/${arch}.tar
186+
podman tag ${arch} ${image_base_sha}-${arch}
187+
podman push ${image_base_sha}-${arch}
188+
podman manifest add ${manifest} ${image_base_sha}-${arch}
189+
done
190+
191+
tags="${{ steps.meta.outputs.tags }}"
192+
193+
for tag in ${tags}; do
194+
podman manifest push ${manifest} $tag
195+
done
118196
119197
- uses: sarisia/actions-status-discord@v1
120198
if: failure()
@@ -123,7 +201,8 @@ jobs:
123201

124202
deploy:
125203
if: (github.event_name != 'pull_request') && !startsWith(github.ref, 'refs/heads/renovate')
126-
needs: build
204+
needs:
205+
- publish_manifest
127206
runs-on: ubuntu-latest
128207
permissions:
129208
contents: write

0 commit comments

Comments
 (0)