-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (77 loc) · 2.41 KB
/
build-actions-runner-images.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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@v5
with:
context: ${{ matrix.context }}
push: true
tags: ${{ env.REGISTRY }}/invakid404/runners/${{ steps.image-name.outputs.name }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max