Get status of parallel jobs into a single Webhook payload #26526
-
I would like to check which of my matrix runs passed and which didnt, and then use a webhook to send this information to a database. Right now I have something like this:
My goal is to send a single webhook that has the success/fail info for every job in my workflow. What’s the easiest way to do this? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @benstear , The matrix job status and combination info can be checked from workflow jobs APIs here with GITHUB RUN_ID. You can add a 2nd job which needs matrix job, use ‘if: always()’ to make sure job2 will be executed when matrix job fails, code sample as below, my checkrun for your reference.
Now you get the info you wanted. If string $jobstatus contains ‘failure’, you can simply mark the whole matrix job status as ‘fail’ ans tranfer to action ‘distributhor/workflow-webhoo’. Note: action parameter doesn’t accept string $jobstatus, you can set is as env (set-env command) |
Beta Was this translation helpful? Give feedback.
-
Thank you @weide-zhou , this is perfect! Two questions:
|
Beta Was this translation helpful? Give feedback.
-
Hi @benstear , Thanks for your reply!
The only way to persist data between different jobs is ‘artifacts’. If you use artifacts to get the job status in each matrix parallel job, in job2, you need to download all of the artifacts, get the content and combine them to single file, transfer to action, it looks more complicated than the API.
|
Beta Was this translation helpful? Give feedback.
Hi @benstear ,
The matrix job status and combination info can be checked from workflow jobs APIs here with GITHUB RUN_ID.
You can add a 2nd job which needs matrix job, use ‘if: always()’ to make sure job2 will be executed when matrix job fails, code sample as below, my checkrun for your reference.