Skip to content

Build Actions Runner Images #50

Build Actions Runner Images

Build Actions Runner Images #50

name: Build Actions Runner Images
on:
push:
branches:
- main
paths:
- apps/arc/runners/**/Dockerfile
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
gather-dockerfiles:
name: Gather Dockerfiles
runs-on: pi-cluster
outputs:
contexts: ${{ github.event_name == 'push' && steps.find-changed.outputs.all_changed_files || steps.find-all.outputs.contexts }}
steps:
- name: Install tools
run: |
sudo apt update && sudo apt install -y git jq
- name: Checkout
uses: actions/checkout@v4
- name: Find all changed Dockerfiles (push)
id: find-changed
if: github.event_name == 'push'
uses: tj-actions/changed-files@v44
with:
files: apps/arc/runners/**/Dockerfile
since_last_remote_commit: true
json: true
escape_json: false
dir_names: true
- name: Find all Dockerfiles (schedule)
id: find-all
if: github.event_name != 'push'
run: |
CONTEXTS=$(find apps/arc/runners \
-name Dockerfile -printf '%h\n' | \
jq -R -s -c 'split("\n")[:-1]')
echo "contexts=${CONTEXTS}" >> "${GITHUB_OUTPUT}"
build-image:
name: Build Image
runs-on: pi-cluster
needs:
- gather-dockerfiles
permissions:
contents: read
packages: write
strategy:
matrix:
context: ${{ fromJSON(needs.gather-dockerfiles.outputs.contexts) }}
concurrency:
group: build-image-${{ matrix.context }}
cancel-in-progress: true
steps:
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4
- name: Build image name
id: image-name
env:
context: ${{ matrix.context }}
run: |
echo "name=${context#apps/arc/runners/}" >> "${GITHUB_OUTPUT}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker login
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
push: true
tags: ${{ env.REGISTRY }}/invakid404/runners/${{ steps.image-name.outputs.name }}:latest