1818 required : true
1919 description : |
2020 The builder tag to use in the build
21+ include-arch-json :
22+ type : string
23+ required : true
24+ description : |
25+ JSON for matrix.include to select architectures and runners to build
2126
2227env :
2328 COLLECTOR_TAG : ${{ inputs.collector-tag }}
3035jobs :
3136 build-collector-image :
3237 name : Build Collector
33- runs-on : ubuntu-24.04
3438 strategy :
35- fail-fast : false
3639 matrix :
37- arch : [amd64, ppc64le, arm64]
40+ include : ${{ fromJSON(inputs.include-arch-json) }}
41+ runs-on : ${{ matrix.runner }}
3842
3943 env :
4044 PLATFORM : linux/${{ matrix.arch }}
@@ -46,11 +50,13 @@ jobs:
4650 submodules : true
4751
4852 - name : Set up QEMU
53+ if : matrix.remote != true
4954 uses : docker/setup-qemu-action@v3
5055 with :
5156 image : tonistiigi/binfmt:qemu-v8.1.5
5257
5358 - name : Set up Docker Buildx
59+ if : matrix.remote != true
5460 uses : docker/setup-buildx-action@v3
5561
5662 - name : Create ansible vars
6268 rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
6369 rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
6470 collector_git_ref: ${{ github.ref }}
71+ collector_git_sha: ${{ github.sha }}
6572 collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}
6673 disable_profiling: ${{ matrix.arch != 'amd64' && matrix.arch != 'arm64' }}
6774 rhacs_eng_image: ${{ env.RHACS_ENG_IMAGE }}
7178 driver_version: ${DRIVER_VERSION}
7279 EOF
7380
74- - name : Build images
75- if : |
76- github.event_name != 'pull_request' ||
77- matrix.arch == 'amd64' ||
78- contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
81+ - name : Build ${{ matrix.arch }} image locally
82+ if : matrix.remote != true
7983 timeout-minutes : 480
8084 run : |
8185 ansible-playbook \
@@ -86,32 +90,21 @@ jobs:
8690 -e @'${{ github.workspace }}/ansible/secrets.yml' \
8791 ansible/ci-build-collector.yml
8892
89- build-collector-image-remote-vm :
90- name : Build Collector on a remote VM
91- runs-on : ubuntu-24.04
92- if : github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
93- strategy :
94- fail-fast : false
95- matrix :
96- arch : [s390x]
97-
98- env :
99- PLATFORM : linux/${{ matrix.arch }}
100-
101- steps :
102- - uses : actions/checkout@v4
103-
10493 - uses : actions/setup-python@v5
94+ if : matrix.remote
10595 with :
10696 python-version : " 3.10"
10797
10898 - uses : ' google-github-actions/auth@v2'
99+ if : matrix.remote
109100 with :
110101 credentials_json : ' ${{ secrets.GOOGLE_CREDENTIALS_COLLECTOR_SVC_ACCT }}'
111102
112103 - uses : ' google-github-actions/setup-gcloud@v2'
104+ if : matrix.remote
113105
114106 - uses : ./.github/actions/setup-vm-creds
107+ if : matrix.remote
115108 with :
116109 gcp-ssh-key : ${{ secrets.GCP_SSH_KEY }}
117110 gcp-ssh-key-pub : ${{ secrets.GCP_SSH_KEY_PUB }}
@@ -126,28 +119,12 @@ jobs:
126119 job-tag : builder
127120
128121 - name : Create Build VMs
122+ if : matrix.remote
129123 run : |
130124 make -C "${{ github.workspace }}/ansible" create-build-vms
131125
132- - name : Create ansible vars
133- run : |
134- cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
135- ---
136- stackrox_io_username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
137- stackrox_io_password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
138- rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
139- rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
140- collector_git_ref: ${{ github.ref }}
141- collector_git_sha: ${{ github.sha }}
142- collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}
143- disable_profiling: ${{ matrix.arch != 'amd64' && matrix.arch != 'arm64' }}
144- rhacs_eng_image: ${{ env.RHACS_ENG_IMAGE }}
145- collector_image: ${{ inputs.collector-image }}
146- collector_tag: ${{ inputs.collector-tag }}
147- debug_mode: ${{ github.event_name == 'pull_request' }}
148- EOF
149-
150- - name : Build ${{ matrix.arch }} image
126+ - name : Build ${{ matrix.arch }} image remotely
127+ if : matrix.remote
151128 timeout-minutes : 480
152129 run : |
153130 ansible-playbook \
@@ -158,21 +135,18 @@ jobs:
158135 ansible/ci-build-collector.yml
159136
160137 - name : Destroy Build VMs
161- if : always()
138+ if : always() && matrix.remote
162139 run : |
163140 make -C ansible destroy-vms
164141
165142 create-multiarch-manifest :
166143 needs :
167144 - build-collector-image
168- - build-collector-image-remote-vm
169145 name : Create Multiarch manifest
170146 runs-on : ubuntu-24.04
171- if : |
172- github.event_name != 'pull_request' ||
173- contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
147+ if : always() && !contains(join(needs.*.result, ','), 'failure')
174148 env :
175- ARCHS : amd64 ppc64le s390x arm64
149+ ARCHS : ${{ join(fromJSON(inputs.include-arch-json).*.arch, ' ') }}
176150
177151 steps :
178152 - uses : actions/checkout@v4
@@ -203,43 +177,12 @@ jobs:
203177 base-image : quay.io/rhacs-eng/collector:${{ inputs.collector-tag }}
204178 archs : ${{ env.ARCHS }}
205179
206- retag-x86-image :
207- needs :
208- - build-collector-image
209- name : Retag x86 image
210- runs-on : ubuntu-24.04
211- if : |
212- github.event_name == 'pull_request' &&
213- !contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
214- steps :
215- - name : Pull image to retag
216- run : |
217- docker pull ${{ inputs.collector-image }}-amd64
218-
219- - name : Retag and push stackrox-io
220- uses : stackrox/actions/images/retag-and-push@v1
221- with :
222- src-image : ${{ inputs.collector-image }}-amd64
223- dst-image : ${{ inputs.collector-image }}
224- username : ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
225- password : ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
226-
227- - name : Retag and push rhacs-eng
228- uses : stackrox/actions/images/retag-and-push@v1
229- with :
230- src-image : ${{ inputs.collector-image }}-amd64
231- dst-image : ${{ env.RHACS_ENG_IMAGE }}
232- username : ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
233- password : ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
234-
235180 notify :
236181 runs-on : ubuntu-24.04
237182 if : always() && contains(join(needs.*.result, ','), 'failure') && github.event_name != 'pull_request'
238183 needs :
239184 - build-collector-image
240- - build-collector-image-remote-vm
241185 - create-multiarch-manifest
242- - retag-x86-image
243186 steps :
244187 - name : Slack notification
245188 uses : rtCamp/action-slack-notify@v2
0 commit comments