Skip to content

Commit b13ef28

Browse files
authored
CI/CD - Merge multi-arch image (#696)
Merge multi-arch image in build pipeline.
1 parent 294f1f2 commit b13ef28

File tree

1 file changed

+90
-17
lines changed

1 file changed

+90
-17
lines changed

.github/workflows/build-image.yml

Lines changed: 90 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,29 @@ on:
1515
workflow_dispatch:
1616

1717
jobs:
18-
docker:
18+
docker-build:
1919
name: Docker build ${{ matrix.name }}
2020
runs-on: ${{ matrix.runner }}
2121
timeout-minutes: 1200
2222
permissions:
2323
contents: read
2424
packages: write
2525
strategy:
26+
fail-fast: true
2627
matrix:
2728
include:
28-
- name: cuda12.8 arm64
29+
- name: cuda12.8-arm64
2930
dockerfile: cuda12.8
30-
tags: superbench/main:cuda12.8
31+
tags: superbench/main:cuda12.8-arm64
3132
platforms: linux/arm64
3233
runner: [self-hosted, linux/arm64]
3334
build_args: "NUM_MAKE_JOBS=16"
34-
- name: cuda12.8
35+
- name: cuda12.8-amd64
3536
dockerfile: cuda12.8
36-
tags: superbench/main:cuda12.8
37+
tags: superbench/main:cuda12.8-amd64
3738
platforms: linux/amd64
3839
runner: [self-hosted, linux/amd64]
3940
build_args: "NUM_MAKE_JOBS=16"
40-
- name: cuda12.4 arm64
41-
dockerfile: cuda12.4
42-
tags: superbench/main:cuda12.4
43-
platforms: linux/arm64
44-
runner: [self-hosted, linux/arm64]
45-
build_args: "NUM_MAKE_JOBS=16"
4641
- name: cuda12.4
4742
dockerfile: cuda12.4
4843
tags: superbench/main:cuda12.4
@@ -61,12 +56,12 @@ jobs:
6156
platforms: linux/amd64
6257
runner: ubuntu-latest
6358
build_args: "NUM_MAKE_JOBS=8"
64-
- name: rocm6.2
65-
dockerfile: rocm6.2.x
66-
tags: superbench/main:rocm6.2
67-
platforms: linux/amd64
68-
runner: [self-hosted, linux/amd64, rocm]
69-
build_args: "NUM_MAKE_JOBS=16"
59+
# - name: rocm6.2
60+
# dockerfile: rocm6.2.x
61+
# tags: superbench/main:rocm6.2
62+
# platforms: linux/amd64
63+
# runner: [self-hosted, linux/amd64, rocm]
64+
# build_args: "NUM_MAKE_JOBS=16"
7065
steps:
7166
- name: Checkout
7267
uses: actions/checkout@v2
@@ -162,3 +157,81 @@ jobs:
162157
org.opencontainers.image.revision=${{ github.sha }}
163158
- name: Echo image digest
164159
run: echo ${{ steps.docker_build.outputs.digest }}
160+
docker-merge:
161+
needs: docker-build
162+
name: Docker merge ${{ matrix.name }}
163+
runs-on: self-hosted
164+
timeout-minutes: 300
165+
permissions:
166+
contents: read
167+
packages: write
168+
strategy:
169+
matrix:
170+
include:
171+
- name: cuda12.8
172+
tags: superbench/main:cuda12.8
173+
sources: >-
174+
superbench/main:cuda12.8-amd64
175+
superbench/main:cuda12.8-arm64
176+
steps:
177+
- name: Checkout
178+
uses: actions/checkout@v4
179+
- name: Prepare metadata
180+
id: metadata
181+
run: |
182+
TAGS=${{ matrix.tags }}
183+
SOURCES="${{ matrix.sources }}"
184+
if [[ "${{ github.event_name }}" == "push" ]] && [[ "${{ github.ref }}" == "refs/heads/release/"* ]]; then
185+
TAGS=$(sed "s/main:/release:${GITHUB_REF##*/}-/g" <<< ${TAGS})
186+
SOURCES=$(sed "s/main:/release:${GITHUB_REF##*/}-/g" <<< ${SOURCES})
187+
fi
188+
if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.base_ref }}" == "release/"* ]]; then
189+
TAGS=$(sed "s/main:/release:${GITHUB_BASE_REF##*/}-/g" <<< ${TAGS})
190+
SOURCES=$(sed "s/main:/release:${GITHUB_BASE_REF##*/}-/g" <<< ${SOURCES})
191+
fi
192+
if [[ "${{ github.event_name }}" == "release" ]]; then
193+
TAGS=$(sed "s/main:/superbench:${GITHUB_REF##*/}-/g" <<< ${TAGS})
194+
GHCR_TAG=$(cut -d, -f1 <<< ${TAGS} | sed "s#superbench/superbench#ghcr.io/${{ github.repository }}/superbench#g")
195+
TAGS="${TAGS},${GHCR_TAG}"
196+
fi
197+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
198+
TAGS=$(sed "s/main:/dev:/g" <<< ${TAGS})
199+
SOURCES=$(sed "s/main:/dev:/g" <<< ${SOURCES})
200+
fi
201+
202+
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
203+
echo "sources=${SOURCES}" >> "$GITHUB_OUTPUT"
204+
- name: Echo image tags
205+
run: echo ${{ steps.metadata.outputs.tags }}
206+
- name: Echo image sourcs
207+
run: echo ${{ steps.metadata.outputs.sources }}
208+
- name: Set up QEMU
209+
uses: docker/setup-qemu-action@v3
210+
- name: Set up Docker Buildx
211+
uses: docker/setup-buildx-action@v3
212+
- name: Login to Docker Hub
213+
uses: docker/login-action@v3
214+
if: ${{ github.event_name != 'pull_request' }}
215+
with:
216+
username: ${{ secrets.DOCKERHUB_USERNAME }}
217+
password: ${{ secrets.DOCKERHUB_TOKEN }}
218+
- name: Login to the GitHub Container Registry
219+
uses: docker/login-action@v3
220+
if: ${{ github.event_name == 'release' }}
221+
with:
222+
registry: ghcr.io
223+
username: ${{ github.actor }}
224+
password: ${{ secrets.GITHUB_TOKEN }}
225+
- name: Merge and push
226+
if: ${{ github.event_name != 'pull_request' }}
227+
run: |
228+
docker buildx imagetools create \
229+
--annotation "index:org.opencontainers.image.source=${{ github.event.repository.html_url }}" \
230+
--annotation "index:org.opencontainers.image.created=${{ github.event.repository.pushed_at }}" \
231+
--annotation "index:org.opencontainers.image.revision=${{ github.sha }}" \
232+
--tag ${{ steps.metadata.outputs.tags }} \
233+
${{ steps.metadata.outputs.sources }}
234+
- name: Inspect image
235+
if: ${{ github.event_name != 'pull_request' }}
236+
run: |
237+
docker buildx imagetools inspect $(echo "${{ steps.metadata.outputs.tags }}" | cut -d, -f1)

0 commit comments

Comments
 (0)