Count the total number of successful steps in a job using github actions #25362
-
Hi all,
Let us suppose I want to run step5 only if anyone of step4 or step3 ran successfully(or both doesn’t skip) how to build such logic around this? If I have some parameters to get the total number of steps ran successfully then this would be done easily. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Hi @uditgaurav,
uditgaurav:
Step status can be got from step context: ‘steps.step_id.outcome’ or ‘steps.step_id.conclusion’. Please check the official doc for more details.
Please change the outcome value according to your requirements.
uditgaurav:
You can check the step context at the last of the job.
My output is as below, you can parse the context of outcome value, and caculate the numbe of successful steps in the job. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi @weide-zhou, I’m running my job on push and have only been seeing an empty object |
Beta Was this translation helpful? Give feedback.
-
Hi @blakethepatton, Please confirm that you add ‘id’ for your steps.
If there still no output, please share your yaml for further investigation. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Yes @weide-zhou, adding id made the steps visible. Thank you so much I’ve spent probably three hours now trying to figure that out! What is the purpose of ID verses name? Other than id implies that it will be unique to that step? |
Beta Was this translation helpful? Give feedback.
-
Hi @blakethepatton, step id is a unique identifier for the step. You can use the Thanks |
Beta Was this translation helpful? Give feedback.
-
Is there a way to access steps from inside a javascript runner without having to explicitly pass it in through an input variable? Additionally, is there a way to get the message behind why a step failed? Or would you need to redirect the console output of the command you’re running into a output variable and then access the error that way. |
Beta Was this translation helpful? Give feedback.
Hi @uditgaurav,
Step status can be got from step context: ‘steps.step_id.outcome’ or ‘steps.step_id.conclusion’. Please check the official doc for more details.
You can use a combined expression for step5, code sample as below: