Skip to content

Commit 278762f

Browse files
authored
ci: publish only freshly built challenge images
1 parent a80f799 commit 278762f

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

.github/workflows/publish-challenges.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ jobs:
4343
- uses: ./.github/actions/setup-nix
4444
- uses: ./.github/actions/setup-challenge-runtime
4545

46+
- name: Build challenge images
47+
id: build-challenge-images
48+
shell: 'nix develop -c bash -euo pipefail {0}'
49+
env:
50+
CHALLENGES_DIR: challenges/${{ matrix.challenges }}
51+
run: |
52+
challenge_images="$RUNNER_TEMP/challenge-images.txt"
53+
./pwnshop build "$CHALLENGES_DIR" | tee "$challenge_images"
54+
echo "challenge_images=$challenge_images" >> "$GITHUB_OUTPUT"
55+
4656
- name: Test challenges
4757
uses: ./.github/actions/test-challenges
4858
with:
@@ -62,10 +72,10 @@ jobs:
6272
containerd_blobs_dir="/mnt/pwn.college/containerd/io.containerd.content.v1.content/blobs"
6373
publish_blobs_dir="/mnt/publish/blobs"
6474
publish_manifests_dir="/mnt/publish/manifests"
75+
challenge_images="${{ steps.build-challenge-images.outputs.challenge_images }}"
6576
sudo mkdir -p "$publish_blobs_dir" "$publish_manifests_dir"
66-
while IFS= read -r line; do
67-
image_id="${line%% *}"
68-
challenge_slug="${line#* }"
77+
while IFS= read -r image_id; do
78+
challenge_slug="$(docker image inspect --format '{{index .Config.Labels "pwncollege.challenge"}}' "$image_id")"
6979
if [ -n "$REGISTRY_SECRET" ]; then
7080
challenge_slug="$REGISTRY_SECRET/$challenge_slug"
7181
fi
@@ -83,10 +93,7 @@ jobs:
8393
done
8494
sudo mkdir -p "$publish_manifests_dir/$challenge_slug"
8595
printf '%s\n' "$image_id" | sudo tee "$publish_manifests_dir/$challenge_slug/latest" >/dev/null
86-
done < <(
87-
docker image ls --filter "label=pwncollege.challenge" --no-trunc --quiet \
88-
| xargs -r docker image inspect --format '{{.Id}} {{index .Config.Labels "pwncollege.challenge"}}'
89-
)
96+
done < "$challenge_images"
9097
{
9198
echo "publish_blobs_dir=$publish_blobs_dir"
9299
echo "publish_manifests_dir=$publish_manifests_dir"

0 commit comments

Comments
 (0)