Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 29 additions & 70 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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 \
.
Loading