I’m writing some utility code for custom GitHub actions. It needs to find its own Step name as it appears in the Web UI. How can this be done?
What I’ve tried so far.
- In contrast to the
GITHUB_WORKFLOW
andGITHUB_JOB
env vars, theGITHUB_ACTION
env var does not contain the name. The former contain the names as they appear in theyaml
, the latter only contains theid
of the step, and if there is no id, a generated name, like__run
, or__actions/checkout_2
. It is also not present in any context object according to the GitHub docs. - The name seems to be available in the API. However, to use the name from the API, i need to find the correct object in the
json
that represents the entire workflow run. TheGITHUB_RUN_ID
makes it easy to identify the workflow. Identifying the job is a bigger problem though. There is noGITHUB_JOB_ID
that would make it easy to identify. Using the name is impossible, because theGITHUB_JOB
env var contains the name as it appears in theyaml
, however, the name from the API contains both a prefix in case its a re-usable workflow representing the calling workflow as well as a postfix in case its a matrix execution. Assuming we would have overcome this, identifying the correct step in the job is just as hard. In theory, since steps are only executed sequentially, the “current” step should be the only one with the statein_progress
. Unfortunately, the API seems to be lagging behind reality, by up to 60 seconds, i.e., the step with the statein_progress
is never the current step. Just in case, the lag is introduced by a HTTP Proxy / server-side cache, I tried adding aCache-Control: no-cache
header, but without success.
How can this be done?