Skip to content

Commit 5606aa4

Browse files
committed
add merging steps for images
1 parent 6807c5d commit 5606aa4

File tree

1 file changed

+105
-3
lines changed

1 file changed

+105
-3
lines changed

.github/workflows/main.yml

+105-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ jobs:
112112
run: |
113113
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
114114
echo "TESTBOX_IMAGE_VERSION=$(./internal/lib/docker_image_info.sh testbox_version)" >> $GITHUB_ENV
115-
export "TESTBOX_BASE_NAME=$(./internal/lib/docker_image_info.sh testbox_base_name)"
116-
echo "TESTBOX_BASE_NAME=$TESTBOX_BASE_NAME" >> $GITHUB_ENV
117-
echo "TESTBOX_IMAGE_NAME=${TESTBOX_BASE_NAME}_${distro//el/rocky_}" >> $GITHUB_ENV
115+
echo "TESTBOX_IMAGE_NAME=$(./internal/lib/docker_image_info.sh testbox_base_name)_rocky_${distro##el}" >> $GITHUB_ENV
118116
echo "DISTRO_NUM=${distro##el}" >> $GITHUB_ENV
119117
env:
120118
platform: linux/${{ matrix.arch.name }}
@@ -170,3 +168,107 @@ jobs:
170168
path: /tmp/digests/*
171169
if-no-files-found: error
172170
retention-days: 1
171+
172+
173+
merge-buildbox:
174+
runs-on: ubuntu-latest
175+
needs:
176+
- build-buildbox
177+
steps:
178+
- uses: actions/checkout@v4
179+
- name: Prepare env
180+
run: |
181+
echo "BUILDBOX_IMAGE_VERSION=$(./internal/lib/docker_image_info.sh buildbox_version)" >> $GITHUB_ENV
182+
echo "BUILDBOX_IMAGE_NAME=$(./internal/lib/docker_image_info.sh buildbox_name)" >> $GITHUB_ENV
183+
184+
- name: Login to GHCR
185+
uses: docker/login-action@v3
186+
with:
187+
registry: ghcr.io
188+
username: ${{ github.repository_owner }}
189+
password: ${{ secrets.GITHUB_TOKEN }}
190+
191+
- name: Set up Docker Buildx
192+
uses: docker/setup-buildx-action@v3
193+
194+
- name: Download digests
195+
uses: actions/download-artifact@v4
196+
with:
197+
path: /tmp/digests
198+
pattern: digests-buildbox-*
199+
merge-multiple: true
200+
201+
- name: Docker meta
202+
id: meta
203+
uses: docker/metadata-action@v5
204+
with:
205+
images: |
206+
ghcr.io/${{ env.BUILDBOX_IMAGE_NAME }}
207+
tags: |
208+
type=raw,value=${{ env.BUILDBOX_IMAGE_VERSION }}
209+
type=raw,value=latest
210+
type=edge,enable=true,priority=700,prefix=,suffix=,branch=$repo.default_branch
211+
212+
- name: Create manifest list and push
213+
working-directory: /tmp/digests
214+
run: docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") $(printf 'ghcr.io/${{ env.BUILDBOX_IMAGE_NAME }}@sha256:%s ' *)
215+
216+
- name: Inspect image
217+
run: docker buildx imagetools inspect ghcr.io/${{ env.BUILDBOX_IMAGE_NAME }}:${{ steps.meta.outputs.version }}
218+
219+
220+
merge-testboxes:
221+
name: Merge ${{ matrix.distro }} Testbox images
222+
runs-on: ubuntu-latest
223+
needs:
224+
- define-matrix
225+
- build-testboxes
226+
strategy:
227+
fail-fast: false
228+
matrix:
229+
distro: ${{ fromJSON(needs.define-matrix.outputs.distros) }}
230+
231+
steps:
232+
- uses: actions/checkout@v4
233+
- name: Prepare env
234+
run: |
235+
echo "TESTBOX_IMAGE_VERSION=$(./internal/lib/docker_image_info.sh testbox_version)" >> $GITHUB_ENV
236+
echo "TESTBOX_IMAGE_NAME=$(./internal/lib/docker_image_info.sh testbox_base_name)_rocky_${distro##el}" >> $GITHUB_ENV
237+
echo "DISTRO_NUM=${distro##el}" >> $GITHUB_ENV
238+
env:
239+
distro: ${{ matrix.distro }}
240+
241+
- name: Login to GHCR
242+
uses: docker/login-action@v3
243+
with:
244+
registry: ghcr.io
245+
username: ${{ github.repository_owner }}
246+
password: ${{ secrets.GITHUB_TOKEN }}
247+
248+
- name: Set up Docker Buildx
249+
uses: docker/setup-buildx-action@v3
250+
251+
- name: Download digests
252+
uses: actions/download-artifact@v4
253+
with:
254+
path: /tmp/digests
255+
pattern: digests-${{ matrix.distro }}-*
256+
merge-multiple: true
257+
258+
- name: Docker meta
259+
id: meta
260+
uses: docker/metadata-action@v5
261+
with:
262+
images: |
263+
ghcr.io/${{ env.TESTBOX_IMAGE_NAME }}
264+
tags: |
265+
type=raw,value=${{ env.TESTBOX_IMAGE_VERSION }}
266+
type=raw,value=latest
267+
type=edge,enable=true,priority=700,prefix=,suffix=,branch=$repo.default_branch
268+
269+
- name: Create manifest list and push
270+
working-directory: /tmp/digests
271+
run: docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") $(printf 'ghcr.io/${{ env.TESTBOX_IMAGE_NAME }}@sha256:%s ' *)
272+
273+
- name: Inspect image
274+
run: docker buildx imagetools inspect ghcr.io/${{ env.TESTBOX_IMAGE_NAME }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)