Build and push runner images / build-runners (pull_request) Failing after 6s
Problem: actions/checkout@v4 requires Node.js, but base forgejo/runner:6 (Alpine) doesn't have it. We need to test our Dockerfiles on the bare base image. Solution: - runs-on: golang (base Alpine runner with dind docker) - Replace actions/checkout@v4 with git clone (no Node.js needed) - Clone to /workspace, run all steps there - Only push on push events (skip on PR to avoid registry pollution) This validates that our Dockerfile fixes work correctly on base image.
65 lines
2.2 KiB
YAML
65 lines
2.2 KiB
YAML
name: Build and push runner images
|
|
|
|
on:
|
|
push:
|
|
paths:
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.golang'
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.rust'
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.node'
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
paths:
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.golang'
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.rust'
|
|
- 'k8s/infra/forgejo-runner/Dockerfile.node'
|
|
- '.gitea/workflows/build-runner-images.yml'
|
|
|
|
jobs:
|
|
build-runners:
|
|
runs-on: golang
|
|
env:
|
|
REGISTRY: forgejo.riotpiao.com
|
|
IMAGE_BASE: forgejo.riotpiao.com/rock
|
|
steps:
|
|
- name: Clone repository (base image, no Node.js required)
|
|
run: |
|
|
git clone --depth 1 https://forgejo.riotpiao.com/rock/homelab.git /workspace
|
|
cd /workspace
|
|
|
|
- name: Get commit SHA
|
|
id: sha
|
|
run: |
|
|
cd /workspace
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
echo "Got SHA: ${SHORT_SHA}"
|
|
|
|
- name: Build all runner images (test on PR, push on main)
|
|
run: |
|
|
cd /workspace
|
|
set -e
|
|
for RUNNER in golang rust node; do
|
|
echo "📦 Building ${RUNNER}-runner..."
|
|
docker build -f "k8s/infra/forgejo-runner/Dockerfile.${RUNNER}" \
|
|
-t "${IMAGE_BASE}/forgejo-runner-${RUNNER}:${{ steps.sha.outputs.short_sha }}" \
|
|
-t "${IMAGE_BASE}/forgejo-runner-${RUNNER}:latest" \
|
|
.
|
|
echo "✅ Built ${RUNNER}-runner"
|
|
done
|
|
|
|
- name: Push images (main only)
|
|
if: github.event_name == 'push'
|
|
run: |
|
|
echo "${REGISTRY_TOKEN}" | docker login "${REGISTRY}" \
|
|
--username "${REGISTRY_USER}" --password-stdin
|
|
for RUNNER in golang rust node; do
|
|
echo "📤 Pushing ${RUNNER}-runner:${{ steps.sha.outputs.short_sha }}"
|
|
docker push "${IMAGE_BASE}/forgejo-runner-${RUNNER}:${{ steps.sha.outputs.short_sha }}"
|
|
docker push "${IMAGE_BASE}/forgejo-runner-${RUNNER}:latest"
|
|
echo "✅ Pushed ${RUNNER}-runner"
|
|
done
|
|
env:
|
|
REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }}
|
|
REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }}
|