runner
runner copied to clipboard
Expose workflow file name (or id) as environment variable?
Currently, we have GITHUB_WORKFLOW
which is either the workflow display name (name
key) or its id (the key in yaml), however there are a few GitHub APIs that use the workflow id (or filename) e.g. get a workflow.
It would be great if these were exposed so that we can use these APIs more easily.
Yes, absolutely needed.
Also found this thread: https://github.community/t/access-workflow-filename-even-when-name-is-defined/17641 This workaround is not really satisfying though.
I would really like this as well, so that I can auto-exclude the workflow file used to trigger the Copy-PR action as otherwise an endless loop is created.
I need it when I using composite action. Because in the case of using that, I want to jump to workflow file where the job is defined from GitHub UI or somewhere. But at least for now, there is not such a feature on GitHub Actions. So I want to print the workflow file name on GitHub Actions but there is no API to get correct filename on steps.
I definitely wish to implement API to get a workflow file name.(IMO full path from root directory is the best)
Also found this thread: https://github.community/t/access-workflow-filename-even-when-name-is-defined/17641 This workaround is not really satisfying though.
This link is broken. Can anyone provide the workaround here?
I posted an answer in https://github.com/orgs/community/discussions/27114. For future reference if the links stop working again:
You can get the workflow ID from the run ID (reference):
workflowId=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/actions/runs/${{ github.run_id }} \
--jq .workflow_id)