How to get the "run" ID?

I have a workflow that calls the Statuses API to set status for a SHA, and I’d like to pass the target_url when creating the status as the URL to go to the Actions GitHub page for the currently-running job:

https://github.com/:user/:repo/runs/:runId

Is there a way to get runId so I can direct users to the job output if a given check (run as a workflow) fails?

Peter

5 Likes

Hi fernap3,

Github Team is working on improving API integration with runners + adding incrementing run ID’s for workflows.

Please see mscoutermarsh’s reply:  

https://github.community/t5/GitHub-Actions/Getting-the-run-id-of-a-run-in-Github-Actions/m-p/41270/highlight/true#M4553

DELTING THIS REPLY, I MESSED UP

Hi @fernap3,

run_id is available in the GitHub context and as an environment variable (GITHUB_RUN_ID) on the runner.

GitHub Context: 

Variable: github.run_id

Docs: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#github-context

Environment variable: 

Variable: GITHUB_RUN_ID

Docs: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables

1 Like

Thanks a lot for this!

I can confirm that I can access the logs for the run in https://github.com/smartpension/api/actions/runs/:runId where :runId is {{ github.run_id }}