Generic url of latest GH Actions run (eg. for use in README.md)

Is there a generic way of getting the latest run url so that it can be used in say a README.md?

eg. instead of:
https://github.com/OCHA-DAP/hdx-python-api/runs/1647792788?check_suite_focus=true

something like this:
https://github.com/OCHA-DAP/hdx-python-api/runs/latest?check_suite_focus=true

or maybe:
https://github.com/OCHA-DAP/hdx-python-api/runs/?check_suite_focus=true&latest=true

where “latest” is a generic term for whatever is the latest run rather than having to supply a specific id.

1 Like

:wave: Hey @mcarans,

There’s no way to reference the latest run URL of a workflow.

If this is intended to be used in a README.md, would a workflow status badge work?
https://docs.github.com/en/actions/managing-workflow-runs/adding-a-workflow-status-badge

Hi @joshmgross. How do you make the badge clickable so that it jumps to the latest run?

As josh said, it’s not supported to reference the latest workflow run with a generic link. You could link to the workflow run overview with a filter for the specific workflow, so that you see the history, latest runs on the top:

https://github.com/<owner>/<repo>/actions/workflows/file-name-of-workflow.yaml

So what you want to embed in your README.md for that would be:

[![example workflow](https://github.com/<owner>/<repo>/actions/workflows/filename.yaml/badge.svg)](https://github.com/<owner>/<repo>/actions/workflows/filename.yaml)

You can also append ?query=branch%3A<name-of-branch> to the workflow overview URL and
?branch=<name-of-branch> to the badge URL if you additionally want to filter by branch.

1 Like

@Simran-B Thanks, I have done that. I’d like to suggest the new feature of a generic link that goes to the latest run. cc @joshmgross

1 Like