3737 runs-on : ubuntu-latest
3838 needs : [pre-flight]
3939 if : |
40- !(needs.pre-flight.outputs.is_deployment_workflow == 'true'
41- || needs.pre-flight.outputs.docs_only == 'true')
40+ (
41+ needs.pre-flight.outputs.is_deployment_workflow == 'false'
42+ && needs.pre-flight.outputs.is_ci_workload == 'true'
43+ ) || (
44+ needs.pre-flight.outputs.is_deployment_workflow == 'false'
45+ && needs.pre-flight.outputs.is_ci_workload == 'false'
46+ && needs.pre-flight.outputs.docs_only == 'false'
47+ )
4248 steps :
4349 - name : Checkout
4450 uses : actions/checkout@v4
@@ -151,7 +157,8 @@ jobs:
151157 (
152158 needs.pre-flight.outputs.docs_only == 'true'
153159 || needs.pre-flight.outputs.is_deployment_workflow == 'true'
154- || success()
160+ || needs.pre-flight.outputs.is_ci_workload == 'true'
161+ || always()
155162 )
156163 && !cancelled()
157164 runs-on : ubuntu-latest
@@ -162,96 +169,33 @@ jobs:
162169
163170 - name : Get workflow result
164171 id : result
172+ shell : bash -x -e -u -o pipefail {0}
165173 env :
166174 GH_TOKEN : ${{ github.token }}
167175 RUN_ID : ${{ github.run_id }}
176+ SKIPPING_IS_ALLOWED : ${{ needs.pre-flight.outputs.docs_only == 'true' || needs.pre-flight.outputs.is_deployment_workflow == 'true' || needs.pre-flight.outputs.is_ci_workload == 'true' }}
168177 run : |
169- # Get workflow run details and check job conclusions
170- LATEST_ATTEMPT=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion != null) | .conclusion] | last')
171- NUM_FAILED=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion == "failure") | .name] | length')
172- NUM_CANCELLED=$(gh run view $RUN_ID --json jobs -q '[.jobs[] | select(.conclusion == "cancelled") | .name] | length')
173-
174- if [[ $NUM_FAILED -eq 0 && $NUM_CANCELLED -eq 0 ]]; then
175- RESULT="success"
176- elif [[ $NUM_CANCELLED -gt 0 ]]; then
177- RESULT="cancelled"
178- else
179- RESULT="failure"
180- fi
181-
182- # Output the final status
183- echo "code=$RESULT" | tee -a $GITHUB_OUTPUT
184-
185- - name : Checkout for GH CLI
186- uses : actions/checkout@v4
187-
188- - name : Remove label if not cancelled
189- if : |
190- steps.result.outputs.code != 'cancelled'
191- && github.event.label.name == 'Run CICD'
192- && github.event.pull_request.head.repo.full_name == github.repository
193- env :
194- GH_TOKEN : ${{ github.token }}
195- PR_NUMBER : ${{ github.event.number }}
196- run : gh pr edit "$PR_NUMBER" --remove-label "Run CICD"
197-
198- - name : Pipeline successful, add PR comment
199- if : |
200- steps.result.outputs.code == 'success'
201- && github.event_name == 'pull_request'
202- && env.SLACK_WEBHOOK != ''
203- uses : peter-evans/create-or-update-comment@v4
204- env :
205- SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK }}
206- REPOSITORY : ${{ github.repository }}
207- RUN_ID : ${{ github.run_id }}
208- with :
209- issue-number : ${{ github.event.number }}
210- body : |
211- [🤖]: Hi @${{ github.event.pull_request.user.login }} 👋,
212-
213- We wanted to let you know that a [CICD pipeline](https://github.com/${{ env.REPOSITORY }}/actions/runs/${{ env.RUN_ID }}) for this PR just finished successfully.
214-
215- So it might be time to merge this PR or get some approvals.
216-
217- //cc @chtruong814 @ko3n1g @pablo-garay @thomasdhc
218-
219- - name : " Pipeline not successful and not cancelled: Send Slack alert & create step summary"
220- if : |
221- steps.result.outputs.code == 'failure'
222- && github.event.label.name == 'Run CICD'
223- && env.SLACK_WEBHOOK != ''
224- env :
225- SLACK_WEBHOOK : ${{ secrets.SLACK_WEBHOOK }}
226- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
227- REPOSITORY : ${{ github.repository }}
228- RUN_ID : ${{ github.run_id }}
229- PR_NUMBER : ${{ github.event.number }}
230- SERVER_URL : ${{ github.server_url }}
231- run : |
232- set -x
233- pip install PyGithub
234- export BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
178+ FAILED_JOBS=$(gh run view $GITHUB_RUN_ID --json jobs --jq '[.jobs[] | select(.status == "completed" and .conclusion != "success")] | length') || echo 0
235179
236- python .github/scripts/notify.py
237-
238- - name : Exit
239- if : ${{ always() }}
240- env :
241- RESULT : ${{ steps.result.outputs.code }}
242- run : |
243- if [ $RESULT == "success" ]; then
244- exit 0
180+ if [ "${FAILED_JOBS:-0}" -eq 0 ] || [ "$SKIPPING_IS_ALLOWED" == "true" ]; then
181+ echo "✅ All previous jobs completed successfully"
182+ exit 0
245183 else
246- exit 1
184+ echo "❌ Found $FAILED_JOBS failed job(s)"
185+ # Show which jobs failed
186+ gh run view $GITHUB_RUN_ID --json jobs --jq '.jobs[] | select(.status == "completed" and .conclusion != "success") | .name'
187+ exit 1
247188 fi
248189
249190 Coverage_Fake :
250191 runs-on : ubuntu-latest
251192 needs : [Nemo_CICD_Test, pre-flight]
252193 if : |
253- (needs.pre-flight.outputs.docs_only == 'true'
254- || needs.pre-flight.outputs.is_deployment_workflow == 'true')
194+ (
195+ needs.pre-flight.outputs.docs_only == 'true'
196+ || needs.pre-flight.outputs.is_deployment_workflow == 'true'
197+ )
198+ && needs.pre-flight.outputs.is_ci_workload == 'false'
255199 && !cancelled()
256200 environment : nemo-ci
257201 steps :
@@ -274,9 +218,8 @@ jobs:
274218 needs : [Nemo_CICD_Test, pre-flight]
275219 if : |
276220 (
277- needs.pre-flight.outputs.docs_only == 'false'
278- && needs.pre-flight.outputs.is_deployment_workflow == 'false'
279- && success()
221+ (needs.pre-flight.outputs.is_ci_workload == 'true' && !failure())
222+ || success()
280223 )
281224 && !cancelled()
282225 strategy :
0 commit comments