Skip to content

Commit 8fbcc2a

Browse files
authored
ci(publish): run on blacksmith-arm (#18)
1 parent 9bfff02 commit 8fbcc2a

File tree

2 files changed

+162
-1
lines changed

2 files changed

+162
-1
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
registry-image:
5+
description: >-
6+
Docker image to use as base name for tags.
7+
required: true
8+
type: string
9+
metadata-tags:
10+
description: >-
11+
List of tags as key-value pair attributes.
12+
required: false
13+
type: string
14+
registry-address:
15+
description: >-
16+
Server address of Docker registry. If not set then will default to Docker registry.
17+
required: false
18+
type: string
19+
default: docker.io
20+
registry-username:
21+
description: >-
22+
Username for authenticating to the Docker registry.
23+
required: true
24+
type: string
25+
build-context:
26+
description: >-
27+
Build's context is the set of files located in the specified PATH or URL.
28+
type: string
29+
required: false
30+
build-file:
31+
description: >-
32+
Path to the Dockerfile.
33+
type: string
34+
required: false
35+
build-provenance:
36+
description: >-
37+
Generate provenance attestation for the build.
38+
required: false
39+
type: boolean
40+
default: false
41+
build-cache-key:
42+
description: >-
43+
An explicit key for a cache entry.
44+
required: false
45+
type: string
46+
default: coatl
47+
build-digest-key:
48+
description: >-
49+
Name of the build digest.
50+
required: false
51+
type: string
52+
default: coatl
53+
secrets:
54+
registry-password:
55+
description: >-
56+
Password or personal access token for authenticating the Docker registry.
57+
required: true
58+
59+
jobs:
60+
build:
61+
runs-on: ${{ matrix.builder.runner-image }}
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
builder:
66+
- runner-image: ubuntu-latest
67+
platform: linux/amd64
68+
- runner-image: blacksmith-arm
69+
platform: linux/arm64
70+
steps:
71+
- name: Prepare
72+
run: |
73+
platform=${{ matrix.builder.platform }}
74+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
75+
76+
- name: Docker meta
77+
id: meta
78+
uses: docker/metadata-action@v5
79+
with:
80+
images: |
81+
${{ inputs.registry-image }}
82+
83+
- name: Set up QEMU
84+
uses: docker/setup-qemu-action@v3
85+
86+
- name: Set up Docker Buildx
87+
uses: docker/setup-buildx-action@v3
88+
89+
- name: Login to Docker registry
90+
uses: docker/login-action@v3
91+
with:
92+
registry: ${{ inputs.registry-address }}
93+
username: ${{ inputs.registry-username }}
94+
password: ${{ secrets.registry-password }}
95+
96+
- name: Build and push by digest
97+
id: build
98+
uses: docker/build-push-action@v6
99+
with:
100+
cache-from: type=gha,scope=${{ inputs.build-cache-key }}-${{ env.PLATFORM_PAIR }}
101+
cache-to: type=gha,scope=${{ inputs.build-cache-key }}-${{ env.PLATFORM_PAIR }},mode=max
102+
context: ${{ inputs.build-context }}
103+
file: ${{ inputs.build-file }}
104+
labels: ${{ steps.meta.outputs.labels }}
105+
outputs: type=image,name=${{ inputs.registry-image }},push-by-digest=true,name-canonical=true,push=true
106+
platforms: ${{ matrix.builder.platform }}
107+
provenance: ${{ inputs.build-provenance }}
108+
109+
- name: Export digest
110+
run: |
111+
mkdir -p /tmp/digests
112+
digest="${{ steps.build.outputs.digest }}"
113+
touch "/tmp/digests/${digest#sha256:}"
114+
115+
- name: Upload digest
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: digests-${{ inputs.build-digest-key }}-${{ env.PLATFORM_PAIR }}
119+
path: /tmp/digests/*
120+
if-no-files-found: error
121+
retention-days: 1
122+
123+
merge:
124+
runs-on: ubuntu-latest
125+
needs:
126+
- build
127+
steps:
128+
- name: Download digests
129+
uses: actions/download-artifact@v4
130+
with:
131+
path: /tmp/digests
132+
pattern: digests-${{ inputs.build-digest-key }}-*
133+
merge-multiple: true
134+
135+
- name: Set up Docker Buildx
136+
uses: docker/setup-buildx-action@v3
137+
138+
- name: Docker meta
139+
id: meta
140+
uses: docker/metadata-action@v5
141+
with:
142+
images: ${{ inputs.registry-image }}
143+
tags: |
144+
${{ inputs.metadata-tags }}
145+
146+
- name: Login to Docker registry
147+
uses: docker/login-action@v3
148+
with:
149+
registry: ${{ inputs.registry-address }}
150+
username: ${{ inputs.registry-username }}
151+
password: ${{ secrets.registry-password }}
152+
153+
- name: Create manifest list and push
154+
working-directory: /tmp/digests
155+
run: |
156+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
157+
$(printf '${{ inputs.registry-image }}@sha256:%s ' *)
158+
159+
- name: Inspect image
160+
run: |
161+
docker buildx imagetools inspect ${{ inputs.registry-image }}:${{ steps.meta.outputs.version }}

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ on:
3434

3535
jobs:
3636
publish:
37-
uses: coatl-dev/workflows/.github/workflows/docker-build-push-multi-platform.yml@v4
37+
uses: ./.github/workflows/docker-build-push-multi-platform.yml
3838
with:
3939
registry-image: ${{ inputs.image }}
4040
metadata-tags: |

0 commit comments

Comments
 (0)