Skip to content

Commit 5398fdd

Browse files
committed
clean up untagged images at the end
1 parent 54ade11 commit 5398fdd

2 files changed

Lines changed: 76 additions & 29 deletions

File tree

.github/workflows/build-and-push-image.yml

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ permissions:
7777
security-events: none
7878
statuses: none
7979

80+
81+
outputs:
82+
amd64:
83+
value: "${{ jobs.build.outputs.amd64 }}"
84+
arm64:
85+
value: "${{ jobs.build.outputs.arm64 }}"
86+
8087
jobs:
8188
build:
8289
runs-on: ${{ fromJSON(github.repository != 'rapidsai/node' && '"ubuntu-latest"' || format('"linux-{0}-cpu4"', matrix.ARCH)) }}
@@ -278,6 +285,7 @@ jobs:
278285
shell: bash --noprofile --norc -eo pipefail {0}
279286
env:
280287
ARCH: ${{ matrix.ARCH }}
288+
REPOSITORY_PREFIX: ${{ env.REGISTRY }}/${{ github.repository_owner }}
281289
STEPS_BUILD_OUTPUTS_DIGEST_AMD64: ${{ steps.build.outputs.digest_amd64 }}
282290
STEPS_BUILD_OUTPUTS_DIGEST_ARM64: ${{ steps.build.outputs.digest_arm64 }}
283291
run: |
@@ -287,7 +295,7 @@ jobs:
287295
DIGEST="${STEPS_BUILD_OUTPUTS_DIGEST_ARM64}"
288296
fi
289297
cat <<EOF >> "$GITHUB_OUTPUT"
290-
${ARCH}={"digest":"${DIGEST}","name":"${IMAGE_NAME}","repo":"${REPOSITORY}","tag":"${IMAGE_TAG}"}
298+
${ARCH}={"digest":"${DIGEST}","name":"${IMAGE_NAME}","repo":"${REPOSITORY#${REPOSITORY_PREFIX}/}","tag":"${IMAGE_TAG}"}
291299
EOF
292300
293301
push:
@@ -305,33 +313,12 @@ jobs:
305313
username: ${{ github.actor }}
306314
password: ${{ github.token }}
307315

308-
- id: push
309-
name: Create manifest in ${{ env.REGISTRY }}
316+
- name: Create manifest in ${{ env.REGISTRY }}
310317
shell: bash --noprofile --norc -eo pipefail {0}
311318
env:
312-
AMD64: ${{ needs.build.outputs.amd64 }}
313-
ARM64: ${{ needs.build.outputs.arm64 }}
314-
REPO: ${{ fromJSON(needs.build.outputs.amd64).repo }}
315-
REPO_PREFIX: "${{ env.REGISTRY }}/${{ github.repository_owner }}"
316-
run: | # zizmor: ignore[template-injection]
317-
# Create the multiarch manifest
318-
docker buildx imagetools create --tag \
319-
"${{ fromJSON(env.AMD64).name }}" \
320-
"${{ fromJSON(env.AMD64).digest }}" \
321-
"${{ fromJSON(env.ARM64).digest }}" \
322-
;
323-
324-
echo "repo=${REPO#${REPO_PREFIX}/}" >> "$GITHUB_OUTPUT";
325-
echo "tags=${{ fromJSON(env.AMD64).tag }}" >> "$GITHUB_OUTPUT";
326-
echo "shas=${{ fromJSON(env.AMD64).digest }} ${{ fromJSON(env.ARM64).digest }}" >> "$GITHUB_OUTPUT";
327-
328-
- name: Clean up untagged images
329-
uses: snok/container-retention-policy@3b0972b2276b171b212f8c4efbca59ebba26eceb
330-
with:
331-
cut-off: 6hr
332-
tag-selection: untagged
333-
token: "${{ github.token }}"
334-
image-tags: "${{ steps.push.outputs.tags }}"
335-
image-names: "${{ steps.push.outputs.repo }}"
336-
skip-shas: "${{ steps.push.outputs.shas }}"
337-
account: "${{ github.actor == github.repository_owner && 'user' || github.repository_owner }}"
319+
IMAGE_NAME: ${{ fromJSON(needs.build.outputs.amd64).name }}
320+
AMD64_HASH: ${{ fromJSON(needs.build.outputs.amd64).digest }}
321+
ARM64_HASH: ${{ fromJSON(needs.build.outputs.arm64).digest }}
322+
# Create the multiarch manifest
323+
run: |
324+
docker buildx imagetools create --tag "$IMAGE_NAME" "$AMD64_HASH" "$ARM64_HASH"

.github/workflows/merge.pr.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,63 @@ jobs:
281281
manual-build: ${{ github.event_name == 'workflow_dispatch' }}
282282
build-args: |
283283
"UCX_VERSION=1.20.0"
284+
285+
cleanup-untagged-images:
286+
name: Clean up untagged images
287+
runs-on: ubuntu-latest
288+
needs:
289+
- build-and-publish-devel-main-image
290+
- build-and-publish-devel-packages-image
291+
- build-and-publish-runtime-cuda-base-image
292+
- build-and-publish-runtime-cudf-image
293+
- build-and-publish-runtime-cuml-image
294+
- build-and-publish-runtime-cugraph-image
295+
- build-and-publish-runtime-cuspatial-image
296+
- build-and-publish-runtime-glfw-image
297+
- build-and-publish-runtime-main-image
298+
- build-and-publish-runtime-demo-image
299+
env:
300+
repo: ${{ fromJSON(needs.build-and-publish-devel-main-image.amd64).repo }}
301+
tags: >
302+
${{ fromJSON(needs.build-and-publish-devel-main-image.amd64).tag }}
303+
${{ fromJSON(needs.build-and-publish-devel-packages-image.amd64).tag }}
304+
${{ fromJSON(needs.build-and-publish-runtime-cuda-base-image.amd64).tag }}
305+
${{ fromJSON(needs.build-and-publish-runtime-cudf-image.amd64).tag }}
306+
${{ fromJSON(needs.build-and-publish-runtime-cuml-image.amd64).tag }}
307+
${{ fromJSON(needs.build-and-publish-runtime-cugraph-image.amd64).tag }}
308+
${{ fromJSON(needs.build-and-publish-runtime-cuspatial-image.amd64).tag }}
309+
${{ fromJSON(needs.build-and-publish-runtime-glfw-image.amd64).tag }}
310+
${{ fromJSON(needs.build-and-publish-runtime-main-image.amd64).tag }}
311+
${{ fromJSON(needs.build-and-publish-runtime-demo-image.amd64).tag }}
312+
digests: >
313+
${{ fromJSON(needs.build-and-publish-devel-main-image.amd64).digest }}
314+
${{ fromJSON(needs.build-and-publish-devel-main-image.arm64).digest }}
315+
${{ fromJSON(needs.build-and-publish-devel-packages-image.amd64).digest }}
316+
${{ fromJSON(needs.build-and-publish-devel-packages-image.arm64).digest }}
317+
${{ fromJSON(needs.build-and-publish-runtime-cuda-base-image.amd64).digest }}
318+
${{ fromJSON(needs.build-and-publish-runtime-cuda-base-image.arm64).digest }}
319+
${{ fromJSON(needs.build-and-publish-runtime-cudf-image.amd64).digest }}
320+
${{ fromJSON(needs.build-and-publish-runtime-cudf-image.arm64).digest }}
321+
${{ fromJSON(needs.build-and-publish-runtime-cuml-image.amd64).digest }}
322+
${{ fromJSON(needs.build-and-publish-runtime-cuml-image.arm64).digest }}
323+
${{ fromJSON(needs.build-and-publish-runtime-cugraph-image.amd64).digest }}
324+
${{ fromJSON(needs.build-and-publish-runtime-cugraph-image.arm64).digest }}
325+
${{ fromJSON(needs.build-and-publish-runtime-cuspatial-image.amd64).digest }}
326+
${{ fromJSON(needs.build-and-publish-runtime-cuspatial-image.arm64).digest }}
327+
${{ fromJSON(needs.build-and-publish-runtime-glfw-image.amd64).digest }}
328+
${{ fromJSON(needs.build-and-publish-runtime-glfw-image.arm64).digest }}
329+
${{ fromJSON(needs.build-and-publish-runtime-main-image.amd64).digest }}
330+
${{ fromJSON(needs.build-and-publish-runtime-main-image.arm64).digest }}
331+
${{ fromJSON(needs.build-and-publish-runtime-demo-image.amd64).digest }}
332+
${{ fromJSON(needs.build-and-publish-runtime-demo-image.arm64).digest }}
333+
steps:
334+
- name: Clean up untagged images
335+
uses: snok/container-retention-policy@3b0972b2276b171b212f8c4efbca59ebba26eceb
336+
with:
337+
cut-off: 6hr
338+
tag-selection: untagged
339+
token: "${{ github.token }}"
340+
image-tags: "${{ env.tags }}"
341+
image-names: "${{ env.repo }}"
342+
skip-shas: "${{ env.digests }}"
343+
account: "${{ github.actor == github.repository_owner && 'user' || github.repository_owner }}"

0 commit comments

Comments
 (0)