|
23 | 23 | name: Determine if builder image needs to be built
|
24 | 24 | runs-on: ubuntu-24.04
|
25 | 25 | outputs:
|
26 |
| - build-image: ${{ steps.changed.outputs.builder-changed }} |
| 26 | + build-image: ${{ steps.check-builder.outputs.build-image }} |
| 27 | + build-multiarch: ${{ steps.build-multiarch.outputs.build-multiarch }} |
27 | 28 | collector-builder-tag: ${{ steps.builder-tag.outputs.collector-builder-tag }}
|
28 | 29 |
|
29 | 30 | steps:
|
@@ -52,20 +53,68 @@ jobs:
|
52 | 53 | echo "COLLECTOR_BUILDER_TAG=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_ENV"
|
53 | 54 | echo "collector-builder-tag=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_OUTPUT"
|
54 | 55 |
|
| 56 | + - name: Check if the builder image should be built |
| 57 | + id: check-builder |
| 58 | + run: | |
| 59 | + function build_builder() { |
| 60 | + echo "build-image=$1" >> "$GITHUB_OUTPUT" |
| 61 | + exit 0 |
| 62 | + } |
| 63 | +
|
| 64 | + if [[ "${{ steps.changed.outputs.builder-changed }}" == "true" ]]; then |
| 65 | + build_builder "true" |
| 66 | + fi |
| 67 | +
|
| 68 | + if [[ "${GITHUB_EVENT_NAME}" == "schedule" ]]; then |
| 69 | + build_builder "true" |
| 70 | + fi |
| 71 | +
|
| 72 | + if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then |
| 73 | + if [[ "${GITHUB_REF_TYPE}" == "tag" || "${GITHUB_REF_NAME}" == release-* ]]; then |
| 74 | + build_builder "true" |
| 75 | + fi |
| 76 | +
|
| 77 | + build_builder "false" |
| 78 | + fi |
| 79 | +
|
| 80 | + # If we got here, we are on a PR event |
| 81 | + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'build-builder-image') }}" == "true" ]]; then |
| 82 | + build_builder "true" |
| 83 | + fi |
| 84 | +
|
| 85 | + build_builder "false" |
| 86 | +
|
| 87 | + - name: Specify if multiarch image should be built |
| 88 | + id: build-multiarch |
| 89 | + run: | |
| 90 | + function run_multiarch() { |
| 91 | + echo "build-multiarch=$1" >> "$GITHUB_OUTPUT" |
| 92 | + exit 0 |
| 93 | + } |
| 94 | +
|
| 95 | + if [[ "${{ steps.check-builder.outputs.build-image }}" == "false" ]]; then |
| 96 | + run_multiarch "false" |
| 97 | + fi |
| 98 | +
|
| 99 | + if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then |
| 100 | + # PRs only run multiarch on demand |
| 101 | + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') }}" == "true" ]]; then |
| 102 | + run_multiarch "true" |
| 103 | + fi |
| 104 | + run_multiarch "false" |
| 105 | + fi |
| 106 | +
|
| 107 | + # Events that are not on PRs always run multiarch |
| 108 | + run_multiarch "true" |
| 109 | +
|
55 | 110 | build-builder-image:
|
56 | 111 | name: Build the builder image
|
57 | 112 | runs-on: ubuntu-24.04
|
58 | 113 | # Multiarch builds sometimes take for eeeeeeeeeever
|
59 | 114 | timeout-minutes: 480
|
60 | 115 | needs:
|
61 | 116 | - builder-needs-rebuilding
|
62 |
| - if: | |
63 |
| - needs.builder-needs-rebuilding.outputs.build-image == 'true' || |
64 |
| - (github.event_name == 'push' && ( |
65 |
| - github.ref_type == 'tag' || startsWith(github.ref_name, 'release-') |
66 |
| - )) || |
67 |
| - contains(github.event.pull_request.labels.*.name, 'build-builder-image') || |
68 |
| - github.event_name == 'schedule' |
| 117 | + if: needs.builder-needs-rebuilding.outputs.build-image == 'true' |
69 | 118 | strategy:
|
70 | 119 | fail-fast: false
|
71 | 120 | matrix:
|
@@ -118,14 +167,7 @@ jobs:
|
118 | 167 | timeout-minutes: 480
|
119 | 168 | needs:
|
120 | 169 | - builder-needs-rebuilding
|
121 |
| - if: | |
122 |
| - needs.builder-needs-rebuilding.outputs.build-image == 'true' || ( |
123 |
| - github.event_name == 'push' && ( |
124 |
| - github.ref_type == 'tag' || startsWith(github.ref_name, 'release-') |
125 |
| - )) || ( |
126 |
| - contains(github.event.pull_request.labels.*.name, 'build-builder-image') && |
127 |
| - contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') |
128 |
| - ) || github.event_name == 'schedule' |
| 170 | + if: needs.builder-needs-rebuilding.outputs.build-multiarch == 'true' |
129 | 171 | strategy:
|
130 | 172 | fail-fast: false
|
131 | 173 | matrix:
|
@@ -206,11 +248,7 @@ jobs:
|
206 | 248 | - build-builder-image-remote-vm
|
207 | 249 | name: Create Multiarch manifest
|
208 | 250 | runs-on: ubuntu-24.04
|
209 |
| - if: | |
210 |
| - github.event_name != 'pull_request' || ( |
211 |
| - needs.builder-needs-rebuilding.outputs.collector-builder-tag != 'master' && |
212 |
| - contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') |
213 |
| - ) |
| 251 | + if : needs.builder-needs-rebuilding.outputs.build-multiarch == 'true' |
214 | 252 | env:
|
215 | 253 | COLLECTOR_BUILDER_TAG: ${{ needs.builder-needs-rebuilding.outputs.collector-builder-tag }}
|
216 | 254 | ARCHS: amd64 ppc64le s390x arm64
|
@@ -250,10 +288,7 @@ jobs:
|
250 | 288 | - build-builder-image
|
251 | 289 | name: Retag x86 builder image
|
252 | 290 | runs-on: ubuntu-24.04
|
253 |
| - if: | |
254 |
| - github.event_name == 'pull_request' && |
255 |
| - needs.builder-needs-rebuilding.outputs.collector-builder-tag != 'master' && |
256 |
| - !contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') |
| 291 | + if : needs.builder-needs-rebuilding.outputs.build-multiarch == 'false' |
257 | 292 | env:
|
258 | 293 | COLLECTOR_BUILDER_TAG: ${{ needs.builder-needs-rebuilding.outputs.collector-builder-tag }}
|
259 | 294 | steps:
|
|
0 commit comments