Skip to content

Commit 1f7fe57

Browse files
committed
ci(pr): add a finalizer to monitor for success
1 parent ddab482 commit 1f7fe57

File tree

2 files changed

+43
-0
lines changed
  • .github/workflows
  • {{cookiecutter.project_name|replace(" ", "")}}/.github/workflows

2 files changed

+43
-0
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,24 @@ jobs:
9191
name: vuln-scan-results
9292
path: vulns.json
9393
if-no-files-found: error
94+
finalizer:
95+
# This gives us something to set as required in the repo settings. Some projects use dynamic fan-outs using matrix strategies and the fromJSON function, so
96+
# you can't hard-code what _should_ run vs not. Having a finalizer simplifies that so you can just check that the finalizer succeeded, and if so, your
97+
# requirements have been met
98+
# Example: https://x.com/JonZeolla/status/1877344137713766516
99+
name: Finalize the pipeline
100+
runs-on: ubuntu-24.04
101+
# Keep this aligned with the below steps
102+
needs: [lint, test]
103+
if: always() # Ensure it runs even if "needs" fail
104+
steps:
105+
# Keep this aligned with the above needs
106+
- name: Check for failed jobs
107+
run: |
108+
if [[ "${{ needs.lint.result }}" == "failure" ||
109+
"${{ needs.test.result }}" == "failure" ]]; then
110+
echo "One or more required jobs failed. Marking finalizer as failed."
111+
exit 1
112+
fi
113+
- name: Finalize
114+
run: echo "Pipeline complete!"

{{cookiecutter.project_name|replace(" ", "")}}/.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,25 @@ jobs:
116116
name: vulns-${{ "{{ env.SANITIZED_PLATFORM }}" }}
117117
path: vulns.*.json
118118
if-no-files-found: error
119+
finalizer:
120+
# This gives us something to set as required in the repo settings. Some projects use dynamic fan-outs using matrix strategies and the fromJSON function, so
121+
# you can't hard-code what _should_ run vs not. Having a finalizer simplifies that so you can just check that the finalizer succeeded, and if so, your
122+
# requirements have been met
123+
# Example: https://x.com/JonZeolla/status/1877344137713766516
124+
name: Finalize the pipeline
125+
runs-on: ubuntu-24.04
126+
# Keep this aligned with the below steps
127+
needs: [lint, test, build]
128+
if: always() # Ensure it runs even if "needs" fail
129+
steps:
130+
# Keep this aligned with the above needs
131+
- name: Check for failed jobs
132+
run: |
133+
if [[ "{% raw %}${{ needs.lint.result }}{% endraw %}" == "failure" ||
134+
"{% raw %}${{ needs.test.result }}{% endraw %}" == "failure" ||
135+
"{% raw %}${{ needs.build.result }}{% endraw %}" == "failure" ]]; then
136+
echo "One or more required jobs failed. Marking finalizer as failed."
137+
exit 1
138+
fi
139+
- name: Finalize
140+
run: echo "Pipeline complete!"

0 commit comments

Comments
 (0)