Skip to content

Commit 91e68fb

Browse files
committed
gha: use ghcr registry instead of local registry for staging
Once we create the oci archive, the digest of the image changes. Therefore, it doesn't match with the digest reported by bootc and set it to the disk image, and the bootc-operator CI is failing in pulling the correct image. In order to preserve the digest, we push a temporary image per PR which will be moved to the final image once the PR is merged and the CI succeeds. Unfortunately, we cannot rely on the local registry since isn't shared across multiple stages. Assisted-by: AI Signed-off-by: Alice Frosi <afrosi@redhat.com>
1 parent 3d1db03 commit 91e68fb

1 file changed

Lines changed: 64 additions & 32 deletions

File tree

.github/workflows/integration-tests.yml

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
non-default-versions: ${{ steps.set-matrix.outputs.non-default-versions }}
5959
default-version: ${{ steps.set-matrix.outputs.default-version }}
6060
fedora-version: ${{ steps.set-matrix.outputs.fedora-version }}
61+
branch-tag: ${{ steps.set-matrix.outputs.branch-tag }}
6162
steps:
6263
- name: Get supported Kubernetes versions
6364
id: set-matrix
@@ -67,10 +68,12 @@ jobs:
6768
ALL=$(curl -s https://endoflife.date/api/kubernetes.json | \
6869
jq -c '[.[] | select(.eol > (now | strftime("%Y-%m-%d"))) | .cycle][:3]')
6970
NON_DEFAULT=$(echo "$ALL" | jq -c --arg default "$DEFAULT" 'map(select(. != $default))')
71+
BRANCH_TAG=$(echo "${{ github.head_ref || github.ref_name }}" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9._-]+/-/g')
7072
echo "all-versions=${ALL}" >> "$GITHUB_OUTPUT"
7173
echo "non-default-versions=${NON_DEFAULT}" >> "$GITHUB_OUTPUT"
7274
echo "default-version=${DEFAULT}" >> "$GITHUB_OUTPUT"
7375
echo "fedora-version=${FEDORA_VERSION}" >> "$GITHUB_OUTPUT"
76+
echo "branch-tag=${BRANCH_TAG}" >> "$GITHUB_OUTPUT"
7477
7578
build-node-images:
7679
needs: [changes, supported-versions]
@@ -80,6 +83,9 @@ jobs:
8083
fail-fast: false
8184
matrix:
8285
kube-minor: ${{ fromJson(needs.supported-versions.outputs.all-versions) }}
86+
permissions:
87+
contents: read
88+
packages: write
8389
steps:
8490
- name: Checkout
8591
uses: actions/checkout@v7
@@ -89,8 +95,8 @@ jobs:
8995
sudo chmod 666 /dev/kvm
9096
ls -la /dev/kvm
9197
92-
- name: Start local registry
93-
run: sudo podman run -d -p 5000:5000 --name registry docker.io/library/registry:2
98+
- name: Log in to GHCR
99+
run: sudo podman login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
94100

95101
- name: Build bootc image
96102
working-directory: node-images/fedora
@@ -101,37 +107,29 @@ jobs:
101107
working-directory: node-images/fedora
102108
run: |
103109
TAG=$(make -s print-image-tag KUBE_MINOR=${{ matrix.kube-minor }})
110+
STAGING_TAG=${{ needs.supported-versions.outputs.branch-tag }}-${TAG}
104111
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
105-
echo "Image tag: ${TAG}"
112+
echo "staging-tag=${STAGING_TAG}" >> "$GITHUB_OUTPUT"
113+
echo "Image tag: ${TAG} (staging: ${STAGING_TAG})"
106114
107-
- name: Push bootc image to local registry
115+
- name: Push bootc image to GHCR (staging)
108116
working-directory: node-images/fedora
109117
run: |
110118
BOOTC_SRC=$(make -s print-bootc-image KUBE_MINOR=${{ matrix.kube-minor }})
111-
sudo podman tag ${BOOTC_SRC} localhost:5000/node:${{ steps.meta.outputs.tag }}
112-
sudo podman push --tls-verify=false localhost:5000/node:${{ steps.meta.outputs.tag }}
119+
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
120+
sudo podman tag ${BOOTC_SRC} ${PUSH_DEST}:${{ steps.meta.outputs.staging-tag }}
121+
sudo podman push ${PUSH_DEST}:${{ steps.meta.outputs.staging-tag }}
113122
114-
- name: Pull bootc image from local registry
123+
- name: Pull bootc image from GHCR
115124
working-directory: node-images/fedora
116125
run: |
117126
BOOTC_SRC=$(make -s print-bootc-image KUBE_MINOR=${{ matrix.kube-minor }})
127+
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
118128
sudo podman rmi ${BOOTC_SRC} || true
119-
sudo podman pull --tls-verify=false localhost:5000/node:${{ steps.meta.outputs.tag }}
120-
sudo podman tag localhost:5000/node:${{ steps.meta.outputs.tag }} ${BOOTC_SRC}
129+
sudo podman pull ${PUSH_DEST}:${{ steps.meta.outputs.staging-tag }}
130+
sudo podman tag ${PUSH_DEST}:${{ steps.meta.outputs.staging-tag }} ${BOOTC_SRC}
121131
echo "Bootc image digest: $(sudo podman inspect --format '{{.Digest}}' ${BOOTC_SRC})"
122132
123-
- name: Save bootc image
124-
working-directory: node-images/fedora
125-
run: |
126-
BOOTC_SRC=$(make -s print-bootc-image KUBE_MINOR=${{ matrix.kube-minor }})
127-
sudo podman save -o ${{ github.workspace }}/bootc-image.tar ${BOOTC_SRC}
128-
129-
- name: Upload bootc image artifact
130-
uses: actions/upload-artifact@v7
131-
with:
132-
name: bootc-image-${{ matrix.kube-minor }}
133-
path: bootc-image.tar
134-
135133
- name: Build disk image
136134
working-directory: node-images/fedora
137135
run: sudo make build-disk-image KUBE_MINOR=${{ matrix.kube-minor }}
@@ -357,11 +355,6 @@ jobs:
357355
- name: Checkout
358356
uses: actions/checkout@v7
359357

360-
- name: Download bootc image artifact
361-
uses: actions/download-artifact@v8
362-
with:
363-
name: bootc-image-${{ matrix.kube-minor }}
364-
365358
- name: Download disk image artifact
366359
uses: actions/download-artifact@v8
367360
with:
@@ -374,7 +367,6 @@ jobs:
374367

375368
- name: Load images
376369
run: |
377-
sudo podman load -i bootc-image.tar
378370
sudo podman load -i node-image.tar
379371
sudo podman load -i node-image-composefs.tar
380372
@@ -383,7 +375,9 @@ jobs:
383375
working-directory: node-images/fedora
384376
run: |
385377
TAG=$(make -s print-image-tag KUBE_MINOR=${{ matrix.kube-minor }})
378+
STAGING_TAG=${{ needs.supported-versions.outputs.branch-tag }}-${TAG}
386379
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
380+
echo "staging-tag=${STAGING_TAG}" >> "$GITHUB_OUTPUT"
387381
388382
- name: Log in to GHCR
389383
run: sudo podman login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
@@ -392,14 +386,12 @@ jobs:
392386
working-directory: node-images/fedora
393387
run: |
394388
TAG=${{ steps.meta.outputs.tag }}
395-
BOOTC_SRC=$(make -s print-bootc-image KUBE_MINOR=${{ matrix.kube-minor }})
389+
STAGING_TAG=${{ steps.meta.outputs.staging-tag }}
396390
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
397391
398-
sudo podman tag ${BOOTC_SRC} ${PUSH_DEST}:${TAG}
399-
sudo podman push ${PUSH_DEST}:${TAG}
392+
sudo skopeo copy docker://${PUSH_DEST}:${STAGING_TAG} docker://${PUSH_DEST}:${TAG}
400393
if [ "${{ matrix.kube-minor }}" = "${{ needs.supported-versions.outputs.default-version }}" ]; then
401-
sudo podman tag ${BOOTC_SRC} ${PUSH_DEST}:latest
402-
sudo podman push ${PUSH_DEST}:latest
394+
sudo skopeo copy docker://${PUSH_DEST}:${STAGING_TAG} docker://${PUSH_DEST}:latest
403395
fi
404396
405397
- name: Push disk image
@@ -429,3 +421,43 @@ jobs:
429421
sudo podman tag ${DISK_SRC} ${PUSH_DEST}:latest-disk-composefs
430422
sudo podman push ${PUSH_DEST}:latest-disk-composefs
431423
fi
424+
425+
cleanup-staged-images:
426+
needs:
427+
[
428+
supported-versions,
429+
build-node-images,
430+
integration-tests,
431+
integration-tests-composefs,
432+
integration-tests-k8s-versions,
433+
push-node-images,
434+
]
435+
# Always run once every consumer of the staged bootc image has finished,
436+
# regardless of whether they succeeded, failed, or were skipped.
437+
if: always() && needs.build-node-images.result != 'skipped'
438+
runs-on: ubuntu-latest
439+
permissions:
440+
packages: write
441+
steps:
442+
- name: Delete staged bootc images from GHCR
443+
env:
444+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
445+
run: |
446+
OWNER=$(echo "${{ env.PUSH_REGISTRY }}" | cut -d'/' -f2)
447+
PACKAGE="$(echo "${{ env.PUSH_REGISTRY }}" | cut -d'/' -f3)/${{ env.PUSH_IMAGE }}"
448+
PACKAGE_ENC="${PACKAGE//\//%2F}"
449+
BRANCH_TAG=${{ needs.supported-versions.outputs.branch-tag }}
450+
451+
for kube_minor in $(echo '${{ needs.supported-versions.outputs.all-versions }}' | jq -r '.[]'); do
452+
TAG="v${kube_minor}-fedora-${{ needs.supported-versions.outputs.fedora-version }}"
453+
STAGING_TAG="${BRANCH_TAG}-${TAG}"
454+
echo "Looking up staged image tag: ${STAGING_TAG}"
455+
VERSION_ID=$(gh api "/orgs/${OWNER}/packages/container/${PACKAGE_ENC}/versions" --paginate \
456+
--jq ".[] | select(.metadata.container.tags[]? == \"${STAGING_TAG}\") | .id" | head -n1)
457+
if [ -n "$VERSION_ID" ]; then
458+
gh api --method DELETE "/orgs/${OWNER}/packages/container/${PACKAGE_ENC}/versions/${VERSION_ID}"
459+
echo "Deleted staged image version ${VERSION_ID} (${STAGING_TAG})"
460+
else
461+
echo "No staged image found for ${STAGING_TAG}, skipping"
462+
fi
463+
done

0 commit comments

Comments
 (0)