-
Notifications
You must be signed in to change notification settings - Fork 17
188 lines (184 loc) · 5.95 KB
/
base-builder.yml
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
---
# Builds our base and builder Docker iamges that it used to build the Production Docker Image(s)
name: Base Builder
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- 'master'
pull_request:
concurrency:
group: base-${{ github.ref }}
cancel-in-progress: true
jobs:
file-check: # Check what files changed if we’re being run in a PR or on a push.
name: Check Modified Files
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
outputs:
run: ${{ steps.check-run.outputs.run }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Check files
id: check-files
uses: tj-actions/changed-files@v45
with:
since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
files: |
.github/workflows/base-builder.yml
base/**
builder/**
- name: Check Run
id: check-run
run: |
if [ "${{ steps.check-files.outputs.any_modified }}" == "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo 'run=true' >> "${GITHUB_OUTPUT}"
else
echo 'run=false' >> "${GITHUB_OUTPUT}"
fi
matrix:
name: Prepare Build Matrix
runs-on: ubuntu-latest
outputs:
build-matrix: ${{ steps.build.outputs.matrix }}
pr-matrix: ${{ steps.pr.outputs.matrix }}
publish-matrix: ${{ steps.publish.outputs.matrix }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Prepare tools
id: prepare
run: |
sudo apt-get update || true
sudo apt-get install -y python3-ruamel.yaml
- name: Prepare Build Check Matrix
id: build
run: |
matrix="$(.github/scripts/gen-matrix-base.py build)"
echo "Generated matrix: ${matrix}"
echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
- name: Prepare PR Check Matrix
id: pr
run: |
matrix="$(.github/scripts/gen-matrix-base.py pr)"
echo "Generated matrix: ${matrix}"
echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
- name: Prepare Publish Matrix
id: publish
run: |
matrix="$(.github/scripts/gen-matrix-base.py publish)"
echo "Generated matrix: ${matrix}"
echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
build-check:
name: Build Check
if: github.event_name == 'pull_request'
needs:
- file-check
- matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.build-matrix) }}
steps:
- name: Skip Check
id: skip
if: needs.file-check.outputs.run != 'true'
run: echo "SKIPPED"
- name: Checkout
if: needs.file-check.outputs.run == 'true'
uses: actions/checkout@v4
- name: Setup Buildx
if: needs.file-check.outputs.run == 'true'
uses: docker/setup-buildx-action@v3
- name: Test Build
if: needs.file-check.outputs.run == 'true'
uses: docker/build-push-action@v6
with:
load: false
push: false
tags: netdata/${{ matrix.image }}:test
file: ./${{ matrix.image }}/Dockerfile.${{ matrix.revision }}
pr-checks:
name: PR Checks
if: github.event_name == 'pull_request'
needs:
- file-check
- build-check
- matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.pr-matrix) }}
steps:
- name: Skip Check
id: skip
if: needs.file-check.outputs.run != 'true'
run: echo "SKIPPED"
- name: Checkout
if: needs.file-check.outputs.run == 'true'
uses: actions/checkout@v4
- name: Setup QEMU
if: matrix.platforms != 'linux/i386' && needs.file-check.outputs.run == 'true'
uses: docker/setup-qemu-action@v3
- name: Setup Buildx
if: needs.file-check.outputs.run == 'true'
uses: docker/setup-buildx-action@v3
- name: Build
if: needs.file-check.outputs.run == 'true'
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platforms }}
load: false
push: false
tags: netdata/${{ matrix.image }}:test
file: ./${{ matrix.image }}/Dockerfile.${{ matrix.revision }}
publish:
name: Publish Images
if: github.event_name == 'push' || (github.event_name == 'schedule' && github.repository == 'netdata/helper-images')
runs-on: ubuntu-latest
needs:
- matrix
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.publish-matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Hub Login
uses: docker/login-action@v3
with:
username: netdatabot
password: ${{ secrets.DOCKER_PASSWORD }}
- name: GitHub Container Registry Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Quay.io Login
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
- name: Quay.io Login
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
- name: Docker Build
uses: docker/build-push-action@v6
with:
platforms: ${{ matrix.platforms }}
push: true
file: ./${{ matrix.image }}/Dockerfile.${{ matrix.revision }}
tags: ${{ matrix.tags }}