|
10 | 10 | GHCR_UI_IMAGE_NAME: "${{ github.repository }}/ui" |
11 | 11 | QUAY_REGISTRY: quay.io |
12 | 12 | QUAY_UI_IMAGE_NAME: instructlab-ui/ui |
13 | | - GHCR_PS_IMAGE_NAME: "${{ github.repository }}/pathservice" |
14 | | - QUAY_PS_IMAGE_NAME: instructlab-ui/pathservice |
15 | 13 |
|
16 | 14 | jobs: |
17 | 15 | build_and_publish_ui_qa_image: |
@@ -187,178 +185,3 @@ jobs: |
187 | 185 | git add deploy/k8s/overlays/openshift/qa/kustomization.yaml |
188 | 186 | git commit -m "[CI AUTOMATION]: Bumping QA UI image to tag: pr-${{ steps.get_pr_number.outputs.result }}" -s |
189 | 187 | git push origin main |
190 | | -
|
191 | | - build_and_publish_ps_qa_image: |
192 | | - name: Push QA pathservice container image to GHCR and QUAY |
193 | | - runs-on: ubuntu-22.04 |
194 | | - environment: registry-creds |
195 | | - permissions: |
196 | | - packages: write |
197 | | - contents: write |
198 | | - attestations: write |
199 | | - id-token: write |
200 | | - |
201 | | - steps: |
202 | | - - name: Check out the repo |
203 | | - uses: actions/checkout@v4 |
204 | | - with: |
205 | | - token: ${{ secrets.BOT_PAT }} |
206 | | - ref: 'main' |
207 | | - |
208 | | - - name: Skip if triggered by GitHub Actions bot |
209 | | - id: check_skip |
210 | | - run: |- |
211 | | - if [[ "$(git log -1 --pretty=format:'%s')" == *"[CI AUTOMATION]:"* ]]; then |
212 | | - echo "Workflow triggered by previous action commit. Skipping." |
213 | | - echo "SKIP_WORKFLOW=true" >> "$GITHUB_ENV" |
214 | | - else |
215 | | - echo "SKIP_WORKFLOW=false" >> "$GITHUB_ENV" |
216 | | - fi |
217 | | -
|
218 | | - - name: Log in to the GHCR container image registry |
219 | | - if: env.SKIP_WORKFLOW == 'false' |
220 | | - uses: docker/login-action@v3 |
221 | | - with: |
222 | | - registry: ${{ env.GHCR_REGISTRY }} |
223 | | - username: ${{ github.actor }} |
224 | | - password: ${{ secrets.GITHUB_TOKEN }} |
225 | | - |
226 | | - - name: Log in to the Quay container image registry |
227 | | - if: env.SKIP_WORKFLOW == 'false' |
228 | | - uses: docker/login-action@v3 |
229 | | - with: |
230 | | - registry: ${{ env.QUAY_REGISTRY }} |
231 | | - username: ${{ secrets.QUAY_USERNAME }} |
232 | | - password: ${{ secrets.QUAY_TOKEN }} |
233 | | - |
234 | | - - name: Set up Docker Buildx |
235 | | - if: env.SKIP_WORKFLOW == 'false' |
236 | | - uses: docker/setup-buildx-action@v3 |
237 | | - |
238 | | - - name: Cache Docker layers |
239 | | - if: env.SKIP_WORKFLOW == 'false' |
240 | | - uses: actions/cache@v4 |
241 | | - with: |
242 | | - path: /tmp/.buildx-cache |
243 | | - key: ${{ runner.os }}-buildx-${{ github.sha }} |
244 | | - restore-keys: | |
245 | | - ${{ runner.os }}-buildx- |
246 | | -
|
247 | | - - name: Get Pull Request Number from Commit |
248 | | - if: env.SKIP_WORKFLOW == 'false' |
249 | | - id: get_pr_number |
250 | | - uses: actions/github-script@v7 |
251 | | - with: |
252 | | - script: | |
253 | | - console.log("Repository owner:", context.repo.owner); |
254 | | - console.log("Repository name:", context.repo.repo); |
255 | | - console.log("Current commit SHA:", context.sha); |
256 | | -
|
257 | | - const prs = await github.rest.pulls.list({ |
258 | | - owner: context.repo.owner, |
259 | | - repo: context.repo.repo, |
260 | | - state: 'closed', |
261 | | - sort: 'updated', |
262 | | - direction: 'desc' |
263 | | - }); |
264 | | - console.log("Number of closed PRs fetched:", prs.data.length); |
265 | | -
|
266 | | - for (const pr of prs.data) { |
267 | | - console.log("Checking PR #", pr.number, "- Merged:"); |
268 | | - if (pr.merged_at != "") { |
269 | | - console.log("Found merged PR:", pr.number); |
270 | | - return pr.number; |
271 | | - } |
272 | | - } |
273 | | -
|
274 | | - console.log("No merged PR found in the recent closed PRs."); |
275 | | - return ''; |
276 | | -
|
277 | | - - name: Extract metadata (tags, labels) for pathservice image |
278 | | - if: env.SKIP_WORKFLOW == 'false' |
279 | | - id: ghcr_ps_meta |
280 | | - uses: docker/metadata-action@v5 |
281 | | - with: |
282 | | - images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_PS_IMAGE_NAME }} |
283 | | - |
284 | | - - name: Extract metadata (tags, labels) for pathservice image |
285 | | - if: env.SKIP_WORKFLOW == 'false' |
286 | | - id: quay_ps_meta |
287 | | - uses: docker/metadata-action@v5 |
288 | | - with: |
289 | | - images: ${{ env.QUAY_REGISTRY }}/${{ env.QUAY_PS_IMAGE_NAME }} |
290 | | - |
291 | | - - name: Build and push QA PS image to ghcr.io |
292 | | - if: env.SKIP_WORKFLOW == 'false' |
293 | | - id: push-ps-ghcr |
294 | | - uses: docker/build-push-action@v6 |
295 | | - with: |
296 | | - context: . |
297 | | - push: true |
298 | | - tags: | |
299 | | - "${{ steps.ghcr_ps_meta.outputs.tags }}" |
300 | | - "${{ env.GHCR_REGISTRY }}/${{ env.GHCR_PS_IMAGE_NAME }}:pr-${{ steps.get_pr_number.outputs.result }}" |
301 | | - labels: ${{ steps.ghcr_ps_meta.outputs.labels }} |
302 | | - platforms: linux/amd64,linux/arm64 |
303 | | - cache-from: type=gha |
304 | | - cache-to: type=gha,mode=max |
305 | | - file: pathservice/Containerfile |
306 | | - |
307 | | - - name: Generate QA PS GHCR artifact attestation |
308 | | - if: env.SKIP_WORKFLOW == 'false' |
309 | | - uses: actions/attest-build-provenance@v2 |
310 | | - with: |
311 | | - subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_PS_IMAGE_NAME}} |
312 | | - subject-digest: ${{ steps.push-ps-ghcr.outputs.digest }} |
313 | | - push-to-registry: true |
314 | | - |
315 | | - - name: Build and push QA PS image to quay.io |
316 | | - if: env.SKIP_WORKFLOW == 'false' |
317 | | - id: push-ps-quay |
318 | | - uses: docker/build-push-action@v6 |
319 | | - with: |
320 | | - context: . |
321 | | - push: true |
322 | | - tags: | |
323 | | - "${{ steps.quay_ps_meta.outputs.tags }}" |
324 | | - "${{ env.QUAY_REGISTRY }}/${{ env.QUAY_PS_IMAGE_NAME }}:pr-${{ steps.get_pr_number.outputs.result }}" |
325 | | - labels: ${{ steps.quay_ps_meta.outputs.labels }} |
326 | | - platforms: linux/amd64,linux/arm64 |
327 | | - cache-from: type=gha |
328 | | - cache-to: type=gha,mode=max |
329 | | - file: pathservice/Containerfile |
330 | | - |
331 | | - - name: Generate QA PS Quay artifact attestation |
332 | | - if: env.SKIP_WORKFLOW == 'false' |
333 | | - uses: actions/attest-build-provenance@v2 |
334 | | - with: |
335 | | - subject-name: ${{ env.QUAY_REGISTRY }}/${{ env.QUAY_PS_IMAGE_NAME}} |
336 | | - subject-digest: ${{ steps.push-ps-quay.outputs.digest }} |
337 | | - push-to-registry: true |
338 | | - |
339 | | - |
340 | | - - name: Update coderefs before code changes |
341 | | - if: env.SKIP_WORKFLOW == 'false' |
342 | | - run: |- |
343 | | - git pull --ff-only |
344 | | -
|
345 | | - - name: Update QA PS Quay image |
346 | | - if: env.SKIP_WORKFLOW == 'false' |
347 | | - id: update_qa_ps_manifest_image |
348 | | - env: |
349 | | - PR_TAG: "pr-${{ steps.get_pr_number.outputs.result }}" |
350 | | - run: |- |
351 | | - sudo wget https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 -O /usr/local/bin/yq |
352 | | - sudo chmod +x /usr/local/bin/yq |
353 | | - yq -i ' |
354 | | - (.images[] | select(.name == "quay.io/${{env.QUAY_PS_IMAGE_NAME}}") | .newTag) = env(PR_TAG) |
355 | | - ' deploy/k8s/overlays/openshift/qa/kustomization.yaml |
356 | | -
|
357 | | - - name: Commit and push bump QA PS Image manifest |
358 | | - if: env.SKIP_WORKFLOW == 'false' |
359 | | - run: |- |
360 | | - git config user.name "platform-engineering-bot" |
361 | | - git config user.email "[email protected]" |
362 | | - git add deploy/k8s/overlays/openshift/qa/kustomization.yaml |
363 | | - git commit -m "[CI AUTOMATION]: Bumping QA PS image to tag: pr-${{ steps.get_pr_number.outputs.result }}" -s |
364 | | - git push origin main |
0 commit comments