runner icon indicating copy to clipboard operation
runner copied to clipboard

Expose workflow file name (or id) as environment variable?

Open billyvg opened this issue 4 years ago • 5 comments

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.

billyvg avatar Dec 09 '20 19:12 billyvg

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.

mktcode avatar Jul 16 '21 10:07 mktcode

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.

harrietrs avatar Oct 28 '22 17:10 harrietrs

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)

sota1235 avatar Sep 14 '23 03:09 sota1235

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?

mwilck avatar Feb 27 '24 09:02 mwilck

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)

infinisil avatar Apr 25 '24 02:04 infinisil