From 16488a7ff59a8ce84fcd49be7ec942291a73fed9 Mon Sep 17 00:00:00 2001 From: Nick Joyce Date: Sat, 28 Nov 2026 12:10:42 +0000 Subject: [PATCH] ci: publish one concatenated arm64 image to GHCR Avoid a separate github-runner-base package (GITHUB_TOKEN could not push the unlinked package) and build base+runner like test.yml. Co-authored-by: Cursor --- .github/workflows/publish.yml | 99 ++++++++++------------------------- 1 file changed, 29 insertions(+), 70 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 062f66fa..7a81c0d2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,7 @@ # Publish the single image selene uses: # ghcr.io/njoyce/docker-github-actions-runner:latest # ubuntu resolute, linux/arm64 only. +# Builds base+runner as one image (same pattern as test.yml). name: Publish selene runner image on: push: @@ -34,13 +35,10 @@ jobs: - name: Image names run: | - ORG=$(echo "$(dirname "${GITHUB_REPOSITORY}")" | awk '{print tolower($0)}') - echo "ORG=${ORG}" >> "$GITHUB_ENV" - echo "BASE_IMAGE=ghcr.io/${ORG}/github-runner-base:latest" >> "$GITHUB_ENV" echo "RUNNER_IMAGE=ghcr.io/${GITHUB_REPOSITORY}:latest" >> "$GITHUB_ENV" echo "RUNNER_SHA_IMAGE=ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA}" >> "$GITHUB_ENV" - echo "TEST_BASE=base-${RELEASE}-${GITHUB_SHA::7}-${PLATFORM}" >> "$GITHUB_ENV" - echo "TEST_RUNNER=runner-${RELEASE}-${GITHUB_SHA::7}-${PLATFORM}" >> "$GITHUB_ENV" + echo "TEST_IMAGE=runner-${RELEASE}-${GITHUB_SHA::7}-${PLATFORM}" >> "$GITHUB_ENV" + echo "FINAL_DOCKERFILE=Dockerfile.final.ubuntu-${RELEASE}" >> "$GITHUB_ENV" - name: Set up QEMU uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 @@ -63,100 +61,61 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and load base image - uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4 - with: - timeout_minutes: 60 - max_attempts: 3 - command: | - docker buildx build \ - --file Dockerfile.base \ - --platform linux/${{ env.PLATFORM }} \ - --tag ${{ env.TEST_BASE }} \ - --load \ - --pull \ - --cache-from type=gha,scope=base-resolute-arm64 \ - --cache-to type=gha,mode=max,scope=base-resolute-arm64 \ - . - - - name: Test base image - uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4 - with: - timeout_minutes: 30 - max_attempts: 3 - command: | - echo "os: ubuntu" >"goss_vars_${TEST_BASE}.yaml" - echo "oscodename: ${RELEASE}" >>"goss_vars_${TEST_BASE}.yaml" - echo "arch: ${PLATFORM}" >>"goss_vars_${TEST_BASE}.yaml" - GOSS_VARS="goss_vars_${TEST_BASE}.yaml" GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 \ - "$HOME/.local/bin/dgoss" run --entrypoint /usr/bin/sleep \ - -e RUNNER_NAME=test -e DEBUG_ONLY=true \ - "${TEST_BASE}" 10 - - - name: Push base image - uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4 - with: - timeout_minutes: 60 - max_attempts: 3 - command: | - docker buildx build \ - --file Dockerfile.base \ - --platform linux/${{ env.PLATFORM }} \ - --tag ${{ env.BASE_IMAGE }} \ - --push \ - --cache-from type=gha,scope=base-resolute-arm64 \ - --cache-to type=gha,mode=max,scope=base-resolute-arm64 \ - . - - - name: Prepare runner Dockerfile - run: sed -i.bak "s|FROM.*|FROM ${BASE_IMAGE}|" Dockerfile + - name: Combine base and runner Dockerfiles + run: | + cp Dockerfile.base "${FINAL_DOCKERFILE}" + sed -i.bak "s/FROM.*/FROM ubuntu:${RELEASE}/" "${FINAL_DOCKERFILE}" + sed "s/^FROM.*//" Dockerfile >>"${FINAL_DOCKERFILE}" + grep FROM "${FINAL_DOCKERFILE}" - - name: Build and load runner image + - name: Build and load image uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4 with: - timeout_minutes: 60 + timeout_minutes: 90 max_attempts: 3 command: | docker buildx build \ - --file Dockerfile \ + --file ${{ env.FINAL_DOCKERFILE }} \ --platform linux/${{ env.PLATFORM }} \ - --tag ${{ env.TEST_RUNNER }} \ + --tag ${{ env.TEST_IMAGE }} \ + --label org.opencontainers.image.source=https://github.com/${{ github.repository }} \ --load \ --pull \ - --cache-from type=gha,scope=runner-resolute-arm64 \ - --cache-to type=gha,mode=max,scope=runner-resolute-arm64 \ + --cache-from type=gha,scope=selene-resolute-arm64 \ + --cache-to type=gha,mode=max,scope=selene-resolute-arm64 \ . - - name: Test runner image + - name: Test image uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4 with: timeout_minutes: 30 max_attempts: 3 command: | - echo "os: ubuntu" >"goss_vars_${TEST_RUNNER}.yaml" - echo "oscodename: ${RELEASE}" >>"goss_vars_${TEST_RUNNER}.yaml" - echo "arch: ${PLATFORM}" >>"goss_vars_${TEST_RUNNER}.yaml" - GOSS_VARS="goss_vars_${TEST_RUNNER}.yaml" GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 \ + echo "os: ubuntu" >"goss_vars_${TEST_IMAGE}.yaml" + echo "oscodename: ${RELEASE}" >>"goss_vars_${TEST_IMAGE}.yaml" + echo "arch: ${PLATFORM}" >>"goss_vars_${TEST_IMAGE}.yaml" + GOSS_VARS="goss_vars_${TEST_IMAGE}.yaml" GOSS_FILE=goss_base.yaml GOSS_SLEEP=1 \ "$HOME/.local/bin/dgoss" run --entrypoint /usr/bin/sleep \ -e RUNNER_NAME=test -e DEBUG_ONLY=true \ - "${TEST_RUNNER}" 10 - GOSS_VARS="goss_vars_${TEST_RUNNER}.yaml" GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 \ + "${TEST_IMAGE}" 10 + GOSS_VARS="goss_vars_${TEST_IMAGE}.yaml" GOSS_FILE=goss_full_defaults.yaml GOSS_SLEEP=1 \ "$HOME/.local/bin/dgoss" run --entrypoint /usr/bin/sleep \ -e RUNNER_NAME=test -e DEBUG_ONLY=true \ - "${TEST_RUNNER}" 10 + "${TEST_IMAGE}" 10 - - name: Push runner image + - name: Push image uses: nick-fields/retry@ad984534de44a9489a53aefd81eb77f87c70dc60 # v4 with: timeout_minutes: 60 max_attempts: 3 command: | docker buildx build \ - --file Dockerfile \ + --file ${{ env.FINAL_DOCKERFILE }} \ --platform linux/${{ env.PLATFORM }} \ --tag ${{ env.RUNNER_IMAGE }} \ --tag ${{ env.RUNNER_SHA_IMAGE }} \ + --label org.opencontainers.image.source=https://github.com/${{ github.repository }} \ --push \ - --cache-from type=gha,scope=runner-resolute-arm64 \ - --cache-to type=gha,mode=max,scope=runner-resolute-arm64 \ + --cache-from type=gha,scope=selene-resolute-arm64 \ + --cache-to type=gha,mode=max,scope=selene-resolute-arm64 \ .