This repository was archived by the owner on Feb 11, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (78 loc) · 2.73 KB
/
build-pr.yml
File metadata and controls
91 lines (78 loc) · 2.73 KB
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
89
90
91
name: Build PR
on:
pull_request:
env:
IMAGE_BASE: "ghcr.io/${{ github.repository_owner }}/github-actions-runner"
jobs:
generate_infos:
uses: fullstack-devops/actions/.github/workflows/generate-build-infos.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
load_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- id: set-matrix
working-directory: images
run: |
flavours=$(ls -I "base"| xargs echo | sed 's/ /,/g')
echo "Building flavours: $flavours"
flavours="{\"flavour\":[\"`echo "$flavours" | sed 's/,/","/g'`\"]}"
echo "matrix=$flavours" >> $GITHUB_OUTPUT
build_base:
runs-on: ubuntu-latest
needs: generate_infos
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build github-actions-runner:base
uses: docker/build-push-action@v4
with:
context: ./images/base
push: true
tags: |
${{ env.IMAGE_BASE }}:base-pr-${{ github.event.pull_request.number }}
build_flavours:
runs-on: ubuntu-latest
needs: [generate_infos, load_matrix, build_base]
strategy:
matrix: ${{ fromJson(needs.load_matrix.outputs.matrix) }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: link child image to current pr
run: |
sed -i --expression "s@FROM ${{ env.IMAGE_BASE }}.*@FROM ${{ env.IMAGE_BASE }}:base-pr-${{ github.event.pull_request.number }}@g" \
images/${{ matrix.flavour }}/Dockerfile
- name: Build github-actions-runner:${{ matrix.flavour }}
uses: docker/build-push-action@v4
with:
context: ./images/${{ matrix.flavour }}
push: false
tags: |
${{ env.IMAGE_BASE }}:${{ matrix.flavour }}-pr-${{ github.event.pull_request.number }}