Skip to content

Commit 019c872

Browse files
committed
Merge multi-arch images
1 parent 82e1445 commit 019c872

File tree

3 files changed

+270
-15
lines changed

3 files changed

+270
-15
lines changed

.github/workflows/debian.yml

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ env:
1717

1818
jobs:
1919
# Build the Docker image for Debian using different versions of GCC and Clang.
20+
# Note, the `os` part of matrix must be kept in sync with the `merge` job below
2021
build:
2122
strategy:
2223
matrix:
@@ -56,8 +57,6 @@ jobs:
5657
steps:
5758
- name: Checkout repository
5859
uses: actions/checkout@v4
59-
- name: Set up QEMU
60-
uses: docker/setup-qemu-action@v3
6160
- name: Set up Docker Buildx
6261
uses: docker/setup-buildx-action@v3
6362
- name: Login to GitHub Registry
@@ -66,7 +65,7 @@ jobs:
6665
registry: ${{ env.CONTAINER_REGISTRY }}
6766
username: ${{ github.repository_owner }}
6867
password: ${{ secrets.GITHUB_TOKEN }}
69-
- name: Determine the Docker image name.
68+
- name: Prepare environment
7069
run: |
7170
# Convert the repository name to lowercase as the organization name is
7271
# uppercase, which is not permitted by the Docker registry. It's 2025 and GitHub
@@ -75,6 +74,8 @@ jobs:
7574
CONTAINER_REPO=${GITHUB_REPO@L}
7675
echo "CONTAINER_REPOSITORY=${CONTAINER_REPO}/debian-${{ matrix.os.release }}" >> $GITHUB_ENV
7776
echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/debian-${{ matrix.os.release }}" >> $GITHUB_ENV
77+
PLATFORM=${{ matrix.architecture.platform }}
78+
echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV
7879
- name: Prepare container metadata
7980
id: meta
8081
uses: docker/metadata-action@v5
@@ -89,6 +90,7 @@ jobs:
8990
org.opencontainers.image.vendor=XRPLF
9091
org.opencontainers.image.title=${{ env.CONTAINER_REPOSITORY }}
9192
- name: Build and push the Docker image
93+
id: build
9294
uses: docker/build-push-action@v6
9395
with:
9496
build-args: |
@@ -104,7 +106,97 @@ jobs:
104106
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
105107
platforms: ${{ matrix.architecture.platform }}
106108
provenance: mode=max
107-
push: ${{ github.event_name != 'pull_request' }}
109+
push: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
108110
sbom: true
109111
labels: ${{ steps.meta.outputs.labels }}
110112
target: ${{ matrix.os.compiler_name }}
113+
- name: Export digest
114+
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
115+
shell: bash
116+
run: |
117+
mkdir -p /tmp/digests
118+
DIGEST="${{ steps.build.outputs.digest }}"
119+
touch "/tmp/digests/${DIGEST#sha256:}"
120+
- name: Upload digest
121+
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-${{ env.PLATFORM_PAIR }}
125+
path: /tmp/digests/*
126+
if-no-files-found: error
127+
retention-days: 1
128+
129+
merge:
130+
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
131+
strategy:
132+
matrix:
133+
os:
134+
- release: bookworm
135+
compiler_name: gcc
136+
compiler_version: 12
137+
- release: bookworm
138+
compiler_name: gcc
139+
compiler_version: 13
140+
- release: bookworm
141+
compiler_name: gcc
142+
compiler_version: 14
143+
- release: bookworm
144+
compiler_name: clang
145+
compiler_version: 16
146+
- release: bookworm
147+
compiler_name: clang
148+
compiler_version: 17
149+
- release: bookworm
150+
compiler_name: clang
151+
compiler_version: 18
152+
- release: bookworm
153+
compiler_name: clang
154+
compiler_version: 19
155+
- release: bookworm
156+
compiler_name: clang
157+
compiler_version: 20
158+
runs-on: ubuntu-24.04
159+
needs:
160+
- build
161+
permissions:
162+
packages: write
163+
steps:
164+
- name: Checkout repository
165+
uses: actions/checkout@v4
166+
- name: Download digests
167+
uses: actions/download-artifact@v4
168+
with:
169+
path: /tmp/digests
170+
pattern: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-*
171+
merge-multiple: true
172+
- name: Set up Docker Buildx
173+
uses: docker/setup-buildx-action@v3
174+
- name: Login to GitHub Registry
175+
uses: docker/login-action@v3
176+
with:
177+
registry: ${{ env.CONTAINER_REGISTRY }}
178+
username: ${{ github.repository_owner }}
179+
password: ${{ secrets.GITHUB_TOKEN }}
180+
- name: Prepare environment
181+
run: |
182+
GITHUB_REPO=${{ github.repository }}
183+
CONTAINER_REPO=${GITHUB_REPO@L}
184+
echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/debian-${{ matrix.os.release }}" >> $GITHUB_ENV
185+
- name: Prepare container metadata
186+
id: meta
187+
uses: docker/metadata-action@v5
188+
with:
189+
images: ${{ env.CONTAINER_IMAGE }}
190+
tags: |
191+
type=raw,value=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
192+
type=sha,prefix=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-sha-
193+
- name: Create manifest list and push
194+
working-directory: /tmp/digests
195+
shell: bash
196+
run: |
197+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
198+
$(printf '${{ env.CONTAINER_IMAGE }}@sha256:%s ' *)
199+
- name: Inspect image
200+
shell: bash
201+
run: |
202+
docker buildx imagetools inspect ${{ env.CONTAINER_IMAGE }}:${{ steps.meta.outputs.version }}

.github/workflows/rhel.yml

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ env:
1616

1717
jobs:
1818
# Build the Docker image for Red Hat Enterprise Linux using different versions
19-
# of GCC and Clang.
20-
gcc:
19+
# of GCC
20+
# Note, the `os` part of matrix must be kept in sync with the `merge` job below
21+
build:
2122
strategy:
2223
matrix:
2324
architecture:
@@ -38,8 +39,6 @@ jobs:
3839
steps:
3940
- name: Checkout repository
4041
uses: actions/checkout@v4
41-
- name: Set up QEMU
42-
uses: docker/setup-qemu-action@v3
4342
- name: Set up Docker Buildx
4443
uses: docker/setup-buildx-action@v3
4544
- name: Login to GitHub Registry
@@ -54,7 +53,7 @@ jobs:
5453
registry: ${{ env.REDHAT_REGISTRY }}
5554
username: ${{ secrets.REDHAT_USER }}
5655
password: ${{ secrets.REDHAT_TOKEN }}
57-
- name: Determine the Docker image name.
56+
- name: Prepare environment
5857
run: |
5958
# Convert the repository name to lowercase as the organization name is
6059
# uppercase, which is not permitted by the Docker registry. It's 2025 and GitHub
@@ -63,6 +62,8 @@ jobs:
6362
CONTAINER_REPO=${GITHUB_REPO@L}
6463
echo "CONTAINER_REPOSITORY=${CONTAINER_REPO}/rhel-${{ matrix.os.release }}" >> $GITHUB_ENV
6564
echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/rhel-${{ matrix.os.release }}" >> $GITHUB_ENV
65+
PLATFORM=${{ matrix.architecture.platform }}
66+
echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV
6667
- name: Prepare container metadata
6768
id: meta
6869
uses: docker/metadata-action@v5
@@ -77,6 +78,7 @@ jobs:
7778
org.opencontainers.image.vendor=XRPLF
7879
org.opencontainers.image.title=${{ env.CONTAINER_REPOSITORY }}
7980
- name: Build and push the Docker image
81+
id: build
8082
uses: docker/build-push-action@v6
8183
with:
8284
build-args: |
@@ -91,7 +93,79 @@ jobs:
9193
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
9294
platforms: ${{ matrix.architecture.platform }}
9395
provenance: mode=max
94-
push: ${{ github.event_name != 'pull_request' }}
96+
push: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
9597
sbom: true
9698
labels: ${{ steps.meta.outputs.labels }}
9799
target: ${{ matrix.os.compiler_name }}
100+
- name: Export digest
101+
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
102+
shell: bash
103+
run: |
104+
mkdir -p /tmp/digests
105+
DIGEST="${{ steps.build.outputs.digest }}"
106+
touch "/tmp/digests/${DIGEST#sha256:}"
107+
- name: Upload digest
108+
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-${{ env.PLATFORM_PAIR }}
112+
path: /tmp/digests/*
113+
if-no-files-found: error
114+
retention-days: 1
115+
116+
merge:
117+
if: ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
118+
strategy:
119+
matrix:
120+
os:
121+
- release: 9.6
122+
compiler_name: gcc
123+
compiler_version: 13
124+
- release: 9.6
125+
compiler_name: gcc
126+
compiler_version: 14
127+
runs-on: ubuntu-24.04
128+
needs:
129+
- build
130+
permissions:
131+
packages: write
132+
steps:
133+
- name: Checkout repository
134+
uses: actions/checkout@v4
135+
- name: Download digests
136+
uses: actions/download-artifact@v4
137+
with:
138+
path: /tmp/digests
139+
pattern: digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-*
140+
merge-multiple: true
141+
- name: Set up Docker Buildx
142+
uses: docker/setup-buildx-action@v3
143+
- name: Login to GitHub Registry
144+
uses: docker/login-action@v3
145+
with:
146+
registry: ${{ env.CONTAINER_REGISTRY }}
147+
username: ${{ github.repository_owner }}
148+
password: ${{ secrets.GITHUB_TOKEN }}
149+
- name: Prepare environment
150+
run: |
151+
GITHUB_REPO=${{ github.repository }}
152+
CONTAINER_REPO=${GITHUB_REPO@L}
153+
echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/rhel-${{ matrix.os.release }}" >> $GITHUB_ENV
154+
- name: Prepare container metadata
155+
id: meta
156+
uses: docker/metadata-action@v5
157+
with:
158+
images: ${{ env.CONTAINER_IMAGE }}
159+
tags: |
160+
type=raw,value=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
161+
type=sha,prefix=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-sha-
162+
- name: Create manifest list and push
163+
working-directory: /tmp/digests
164+
shell: bash
165+
run: |
166+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
167+
$(printf '${{ env.CONTAINER_IMAGE }}@sha256:%s ' *)
168+
- name: Inspect image
169+
shell: bash
170+
run: |
171+
docker buildx imagetools inspect ${{ env.CONTAINER_IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)