Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 23

Getting the run id of a run in Github Actions

Solved! Go to Solution.

I have a usecase where I want to share the log of the github action, sharing a github action log would be sharing something like https://github.com/org/repo/runs/284492795

 

Currently we only have `GITHUB_SHA` this shows the log in that SHA but the specific run is not shown, having the run id as a variable can help in better navigation of the logs from external services using Github Actions.

 

Export the run id in the run context or as an env variable somehow.

from this url:

https://github.com/org/repo/runs/284492795

i assume 284492795 is the run id.

 

 

22 Replies
Highlighted
Copilot Lvl 3
Message 2 of 23

Re: Getting the run id of a run in Github Actions

+1.....................

Highlighted
GitHub Partner
Message 3 of 23

Re: Getting the run id of a run in Github Actions

Hi @geekodour @krasi-georgiev ,

 

You can try using the GitHub REST APIs to get the IDs of the runs in a workflow.

The following API is used to get all the runs in a specific workflow/check suite.

GET https://api.github.com/repos/<org>/<repo>/check-suites/<check_suite_id>/check-runs

From the Response body of the API you can get the IDs of the runs.

 

If you want to get the runs from multiple workflows/check suites, at first you can use the following API to get all the workflows/check suites in a specific repository.

GET https://api.github.com/repos/BrightRan/TestClock/commits/master/check-suites

From the Response body of the API you can get the IDs of the workflows/check suites.

 

More details about the GitHub REST API, please reference here: https://developer.github.com/v3/checks/

Highlighted
Copilot Lvl 3
Message 4 of 23

Re: Getting the run id of a run in Github Actions

Yes, there is API for that, but that could not uniquely identify the current run-id.

See also https://github.community/t5/GitHub-Actions/Check-Suite-identifier-as-an-environment-variable/m-p/354...
Highlighted
Copilot Lvl 3
Message 5 of 23

Re: Getting the run id of a run in Github Actions

Thankyou for the response,

where do we get the <check_suit_id> from? but even if we do according to your reply we get a list of run id, which is not what is required. We just want the run-id of the current run. This I think should be passed to the `runner` context aswell.

Highlighted
Copilot Lvl 2
Message 6 of 23

Re: Getting the run id of a run in Github Actions

This seems a big ommision, coming from Azure Pipelines where we have build-ids and release-ids provided as builtin variables which uniquely identify the run, it's left me a little lost.

I generally use these ids to tag build artifacts (e.g. container images) when building, and when releasing use the release run-id as a way to name my kubernetes/cloud resources, e.g. endpoints, Helm release names etc.

 

 

Highlighted
Ground Controller Lvl 1
Message 7 of 23

Re: Getting the run id of a run in Github Actions

In exactly this situation, need a unique number which increments each time a run in trigged for versioning outputted assets.

In the current Azure Devops build I use `Build.BuildIdso the version is v1.1.$BUILD_ID

 

https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#...

 

 

GitHub Staff
Message 8 of 23

Re: Getting the run id of a run in Github Actions

UPDATE: This is now available see here.

 

 

Thanks all. We're working on this.

 

We're improving API integration with runners + adding incrementing run ID's for workflows. With new environment variables to make them easy to work with.

Highlighted
Copilot Lvl 2
Message 9 of 23

Re: Getting the run id of a run in Github Actions


@mscoutermarsh wrote:

Thanks all. We're working on this.

 

We're improving API integration with runners + adding incrementing run ID's for workflows. With new environment variables to make them easy to work with.


 

Is there an issue open that I can follow to know when this is ready?

Highlighted
GitHub Staff
Message 10 of 23

Re: Getting the run id of a run in Github Actions

Follow https://twitter.com/ghchangelog and we'll be sharing there when it's released.

 

Should be within the next month.