8
8
required : true
9
9
description : |
10
10
The tag used to build the collector image
11
+
11
12
outputs :
12
13
collector-builder-tag :
13
14
description : The builder tag used by the build
14
- value : ${{ jobs.build- builder-image .outputs.collector-builder-tag || 'master' }}
15
+ value : ${{ jobs.builder-needs-rebuilding .outputs.collector-builder-tag }}
15
16
16
17
env :
17
18
COLLECTOR_TAG : ${{ inputs.collector-tag }}
23
24
name : Determine if builder image needs to be built
24
25
runs-on : ubuntu-24.04
25
26
outputs :
26
- build-image : ${{ steps.changed.outputs.builder-changed }}
27
+ build-image : ${{ steps.builder-tag.outputs.build-image || false }}
28
+ collector-builder-tag : ${{ steps.builder-tag.outputs.collector-builder-tag || 'master'}}
29
+
30
+ env :
31
+ DEFAULT_BUILDER_TAG : master
27
32
28
33
steps :
29
34
- uses : actions/checkout@v4
@@ -38,106 +43,76 @@ jobs:
38
43
- builder/Dockerfile
39
44
- .github/workflows/collector-builder.yml
40
45
46
+ - name : Check labels and define builder tag
47
+ id : builder-tag
48
+ if : |
49
+ steps.changed.outputs.builder-changed == 'true' ||
50
+ (github.event_name == 'push' && (
51
+ github.ref_type == 'tag' || startsWith(github.ref_name, 'release-')
52
+ )) ||
53
+ contains(github.event.pull_request.labels.*.name, 'build-builder-image') ||
54
+ github.event_name == 'schedule'
55
+ run : |
56
+ COLLECTOR_BUILDER_TAG="${DEFAULT_BUILDER_TAG}"
57
+ if [[ "${{ github.event_name }}" == 'pull_request' || \
58
+ "${{ github.ref_type }}" == 'tag' || \
59
+ "${{ github.ref_name }}" =~ ^release- ]]; then
60
+ COLLECTOR_BUILDER_TAG="${{ inputs.collector-tag }}"
61
+ fi
62
+
63
+ echo "::notice::Rebuild builder image with tag ${COLLECTOR_BUILDER_TAG}"
64
+ echo "collector-builder-tag=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_OUTPUT"
65
+ echo "build-image=true" >> "$GITHUB_OUTPUT"
66
+
41
67
build-builder-image :
42
- name : Build the builder image
43
- runs-on : ubuntu-24.04
44
- # Multiarch builds sometimes take for eeeeeeeeeever
45
- timeout-minutes : 480
68
+ name : Build builder image
46
69
needs :
47
70
- builder-needs-rebuilding
48
71
if : |
49
- needs.builder-needs-rebuilding.outputs.build-image == 'true' ||
50
- (github.event_name == 'push' && (
51
- github.ref_type == 'tag' || startsWith(github.ref_name, 'release-')
52
- )) ||
53
- contains(github.event.pull_request.labels.*.name, 'build-builder-image') ||
54
- github.event_name == 'schedule'
55
- outputs :
56
- collector-builder-tag : ${{ steps.builder-tag.outputs.collector-builder-tag }}
72
+ needs.builder-needs-rebuilding.outputs.build-image == 'true'
57
73
strategy :
58
- fail-fast : false
59
74
matrix :
60
- arch : [amd64, ppc64le, s390x, arm64]
75
+ arch :
76
+ - amd64
77
+ - arm64
78
+ - ppc64le
79
+ - s390x
80
+ runs-on : ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') ||
81
+ (matrix.arch == 'ppc64le' && 'ubuntu-24.04-ppc64le') ||
82
+ (matrix.arch == 's390x' && 'ubuntu-24.04-s390x') ||
83
+ ' ubuntu-24.04' }}
61
84
62
85
env :
63
86
PLATFORM : linux/${{ matrix.arch }}
64
87
BUILD_TYPE : ci
88
+ COLLECTOR_BUILDER_TAG : ${{ needs.builder-needs-rebuilding.outputs.collector-builder-tag }}
65
89
66
90
steps :
67
91
- uses : actions/checkout@v4
68
92
with :
69
93
submodules : true
70
94
71
- - name : Set up QEMU
72
- uses : docker/setup-qemu-action@v3
73
- with :
74
- image : tonistiigi/binfmt:qemu-v8.1.5
75
-
76
95
- name : Set up Docker Buildx
77
96
uses : docker/setup-buildx-action@v3
78
97
79
- - uses : actions/setup-python@v5
80
- with :
81
- python-version : " 3.10"
82
-
83
- - uses : ' google-github-actions/auth@v2'
84
- with :
85
- credentials_json : ' ${{ secrets.GOOGLE_CREDENTIALS_COLLECTOR_SVC_ACCT }}'
86
-
87
- - uses : ' google-github-actions/setup-gcloud@v2'
88
-
89
- - uses : ./.github/actions/setup-vm-creds
90
- with :
91
- gcp-ssh-key : ${{ secrets.GCP_SSH_KEY }}
92
- gcp-ssh-key-pub : ${{ secrets.GCP_SSH_KEY_PUB }}
93
- s390x-ssh-key : ${{ secrets.IBM_CLOUD_S390X_SSH_PRIVATE_KEY }}
94
- ppc64le-ssh-key : ${{ secrets.IBM_CLOUD_POWER_SSH_PRIVATE_KEY }}
95
- ppc64le-ssh-key-pub : ${{ secrets.IBM_CLOUD_POWER_SSH_PUBLIC_KEY }}
96
- s390x-key : ${{ secrets.IBM_CLOUD_S390x_API_KEY }}
97
- ppc64le-key : ${{ secrets.IBM_CLOUD_POWER_API_KEY }}
98
- redhat-username : ${{ secrets.REDHAT_USERNAME }}
99
- redhat-password : ${{ secrets.REDHAT_PASSWORD }}
100
- vm-type : all
101
- job-tag : builder
102
-
103
- - name : Create Build VMs
104
- if : |
105
- matrix.arch == 's390x' &&
106
- (github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds'))
98
+ - name : Install ansible on P&Z runners
99
+ if : matrix.arch == 'ppc64le' || matrix.arch == 's390x'
107
100
run : |
108
- make -C "${{ github.workspace }}/ansible" create-build-vms
109
-
110
- - name : Define builder tag
111
- id : builder-tag
112
- run : |
113
- COLLECTOR_BUILDER_TAG="${DEFAULT_BUILDER_TAG}"
114
- if [[ "${{ github.event_name }}" == 'pull_request' || \
115
- "${{ github.ref_type }}" == 'tag' || \
116
- "${{ github.ref_name }}" =~ ^release- ]]; then
117
- COLLECTOR_BUILDER_TAG="${{ inputs.collector-tag }}"
118
- fi
119
-
120
- echo "COLLECTOR_BUILDER_TAG=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_ENV"
121
- echo "collector-builder-tag=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_OUTPUT"
101
+ sudo apt-get install -y ansible
122
102
123
103
- name : Create ansible vars
124
104
run : |
125
- {
126
- echo " ---"
127
- echo " stackrox_io_username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}"
128
- echo " stackrox_io_password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}"
129
- echo " rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}"
130
- echo " rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}"
131
- echo " collector_git_ref: ${{ github.ref }}"
132
- echo " collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}"
133
- } > ${{ github.workspace }}/ansible/secrets.yml
105
+ cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
106
+ ---
107
+ stackrox_io_username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
108
+ stackrox_io_password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
109
+ rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
110
+ rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
111
+ collector_git_ref: ${{ github.ref }}
112
+ collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}
113
+ EOF
134
114
135
115
- name : Build images
136
- if : |
137
- (github.event_name != 'pull_request' && matrix.arch != 's390x') ||
138
- matrix.arch == 'amd64' ||
139
- (contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') && matrix.arch != 's390x')
140
- timeout-minutes : 480
141
116
run : |
142
117
ansible-galaxy install -r ansible/requirements.yml
143
118
ansible-playbook \
@@ -148,36 +123,18 @@ jobs:
148
123
-e @'${{ github.workspace }}/ansible/secrets.yml' \
149
124
ansible/ci-build-builder.yml
150
125
151
- - name : Build s390x images
152
- if : |
153
- (github.event_name != 'pull_request' && matrix.arch == 's390x') ||
154
- (contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') && matrix.arch == 's390x')
155
- timeout-minutes : 480
156
- run : |
157
- ansible-playbook \
158
- -i ansible/ci \
159
- -e build_hosts='job_id_${{ env.JOB_ID }}' \
160
- -e arch='${{ matrix.arch }}' \
161
- -e @'${{ github.workspace }}/ansible/secrets.yml' \
162
- ansible/ci-build-builder.yml
163
-
164
- - name : Destroy VMs
165
- if : always() && matrix.arch == 's390x'
166
- run : |
167
- make -C ansible destroy-vms
168
-
169
126
create-multiarch-manifest :
170
127
needs :
128
+ - builder-needs-rebuilding
171
129
- build-builder-image
172
130
name : Create Multiarch manifest
173
131
runs-on : ubuntu-24.04
174
132
if : |
175
- github.event_name != 'pull_request' ||
176
- (needs.build-builder-image.outputs.collector-builder-tag != 'cache' &&
177
- contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds'))
133
+ always() && !contains(join(needs.*.result, ','), 'failure') &&
134
+ needs.builder-needs-rebuilding.outputs.build-image == 'true'
178
135
env :
179
- COLLECTOR_BUILDER_TAG : ${{ needs.build- builder-image .outputs.collector-builder-tag }}
180
- ARCHS : amd64 ppc64le s390x arm64
136
+ COLLECTOR_BUILDER_TAG : ${{ needs.builder-needs-rebuilding .outputs.collector-builder-tag }}
137
+ ARCHS : amd64 arm64 ppc64le s390x
181
138
182
139
steps :
183
140
- uses : actions/checkout@v4
@@ -208,45 +165,12 @@ jobs:
208
165
base-image : quay.io/rhacs-eng/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}
209
166
archs : ${{ env.ARCHS }}
210
167
211
- retag-x86-image :
212
- needs :
213
- - build-builder-image
214
- name : Retag x86 builder image
215
- runs-on : ubuntu-24.04
216
- if : |
217
- github.event_name == 'pull_request' &&
218
- needs.build-builder-image.outputs.collector-builder-tag != 'cache' &&
219
- !contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
220
- env :
221
- COLLECTOR_BUILDER_TAG : ${{ needs.build-builder-image.outputs.collector-builder-tag }}
222
- steps :
223
- - name : Pull image to retag
224
- run : |
225
- docker pull "quay.io/stackrox-io/collector-builder:${COLLECTOR_BUILDER_TAG}-amd64"
226
-
227
- - name : Retag and push stackrox-io
228
- uses : stackrox/actions/images/retag-and-push@v1
229
- with :
230
- src-image : quay.io/stackrox-io/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}-amd64
231
- dst-image : quay.io/stackrox-io/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}
232
- username : ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
233
- password : ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
234
-
235
- - name : Retag and push rhacs-eng
236
- uses : stackrox/actions/images/retag-and-push@v1
237
- with :
238
- src-image : quay.io/stackrox-io/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}-amd64
239
- dst-image : quay.io/rhacs-eng/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}
240
- username : ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
241
- password : ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
242
-
243
168
notify :
244
169
runs-on : ubuntu-24.04
245
170
if : always() && contains(join(needs.*.result, ','), 'failure') && github.event_name != 'pull_request'
246
171
needs :
247
172
- build-builder-image
248
173
- create-multiarch-manifest
249
- - retag-x86-image
250
174
steps :
251
175
- name : Slack notification
252
176
uses : rtCamp/action-slack-notify@v2
0 commit comments