Skip to content

Commit 2d00d30

Browse files
committed
ci: Improvement
* ci: Prevent notification on cancelled workflows * ci: Update failure condition to check job results * ci: Add missing job dependencies to notify job * ci: Validate required jobs in finished job
1 parent a7dbb73 commit 2d00d30

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

template/.github/workflows/build.yaml.j2

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,28 +392,44 @@ jobs:
392392
# WARNING: Do not change the name unless you will also be changing the
393393
# Required Checks (in branch protections) in GitHub settings.
394394
name: Finished Build and Publish
395+
if: always()
395396
needs:
397+
- detect-changes
396398
- cargo-udeps
399+
- build-container-image
400+
- publish-index-manifest
397401
- openshift-preflight-check
398402
- publish-helm-chart
403+
- provenance-oci
404+
- provenance-quay
399405
runs-on: ubuntu-latest
400406
steps:
401-
- run: echo "We are done here"
407+
- name: Fail if a required job failed or was cancelled
408+
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
409+
run: |
410+
echo "One or more required jobs failed or were cancelled."
411+
exit 1
412+
413+
- name: Finished
414+
run: echo "All required jobs succeeded or were intentionally skipped."
402415

403416
notify:
404417
name: Failure Notification
405418
if: |
406-
(failure() || github.run_attempt > 1)
419+
!cancelled()
420+
&& (contains(needs.*.result, 'failure') || github.run_attempt > 1)
407421
&& github.event_name != 'merge_group'
408422
&& needs.detect-changes.outputs.detected == 'true'
409423
&& !github.event.pull_request.head.repo.fork
410424
needs:
411425
- detect-changes
426+
- cargo-udeps
412427
- build-container-image
413428
- publish-index-manifest
414429
- provenance-oci
415430
- provenance-quay
416431
- publish-helm-chart
432+
- openshift-preflight-check
417433
- finished
418434
runs-on: ubuntu-latest
419435
steps:

0 commit comments

Comments
 (0)