Debian Runner Build (push) #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Debian Runners | |
run-name: Debian Runner Build (${{ github.event_name }}) | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "runner/**" | |
- "!runner/Makefile" | |
- "debian/**" | |
- ".github/workflows/debian-runners.yaml" | |
- "!**.md" | |
workflow_dispatch: | |
inputs: | |
force-push: | |
description: "push to GHCR" | |
type: boolean | |
required: true | |
default: false | |
defaults: | |
run: | |
shell: bash | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
RUNNER_VERSION: 2.299.1 | |
DOCKER_VERSION: 20.10.12 | |
RUNNER_CONTAINER_HOOKS_VERSION: 0.1.2 | |
jobs: | |
build-runners: | |
name: ${{ matrix.os-name }}-${{ matrix.os-version }} ${{ matrix.name }} | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
name: [actions-runner, actions-runner-dind] | |
os-name: [debian] | |
os-version: [11, 12] | |
include: | |
- os-version: 11 | |
tag-latest: true | |
tag-os: true | |
- os-version: 12 | |
tag-latest: false | |
tag-os: false | |
steps: | |
- name: Checkout | |
id: checkout | |
uses: actions/checkout@v4 | |
- name: Get short SHA ref | |
id: vars | |
run: | | |
echo "sha_short=${GITHUB_SHA::8}" >> $GITHUB_ENV | |
- name: Map debian version to name | |
id: version-map | |
run: | | |
case ${{ matrix.os-version }} in | |
11) | |
echo "os_version_name=bullseye" >> $GITHUB_ENV | |
;; | |
12) | |
echo "os_version_name=bookworm" >> $GITHUB_ENV | |
;; | |
*) | |
echo "Unable to map '${{ matrix.os-version }}' to a release name..." | |
exit 1 | |
;; | |
esac | |
- name: Set build dockerfile | |
id: Copy | |
run: | | |
if [[ -d "${{ matrix.os-name }}" ]]; then | |
cp ${{ matrix.os-name }}/${{ matrix.name }}-${{ env.os_version_name }}.dockerfile \ | |
./runner/${{ matrix.name }}-${{ matrix.os-name }}.dockerfile || exit 1 | |
echo "Using custom dockerfile from ${{ matrix.os-name }}" | |
else | |
# Passthrough build, rename the upstream dockerfile | |
cp runner/${{ matrix.name }}.dockerfile runner/${{ matrix.name }}-${{ matrix.os-name }}.dockerfile || exit 1 | |
echo "Doing passthrough build from upstream dockerfile" | |
fi | |
- name: Set up QEMU | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }}/${{ matrix.name }} | |
tags: | | |
type=raw,value=latest,enable=${{ matrix.tag-latest }} | |
type=raw,value=${{ matrix.os-name }},enable=${{ matrix.tag-os }} | |
type=raw,value=${{ matrix.os-name }}-${{ matrix.os-version }} | |
type=raw,value=${{ matrix.os-name }}-${{ env.os_version_name }} | |
type=raw,value=v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }} | |
type=raw,value=v${{ env.RUNNER_VERSION }}-${{ matrix.os-name }}-${{ matrix.os-version }}-${{ env.sha_short }} | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Versioned Tags | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./runner | |
file: ./runner/${{ matrix.name }}-${{ matrix.os-name }}.dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || inputs.force-push }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
PARENT_IMAGE=${{ matrix.os-name }}:${{ env.os_version_name }} | |
RUNNER_VERSION=${{ env.RUNNER_VERSION }} | |
DOCKER_VERSION=${{ env.DOCKER_VERSION }} | |
RUNNER_CONTAINER_HOOKS_VERSION=${{ env.RUNNER_CONTAINER_HOOKS_VERSION }} | |
cache-from: type=gha,scope=build-${{ matrix.name }} | |
cache-to: type=gha,mode=max,scope=build-${{ matrix.name }} |