-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial implementation #1
Conversation
What's the motivation for this? |
Knowing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems really really cursed but with reasonable test coverage I'm okay with it.
Thanks Dave. I'll merge this and make the first release on Monday! |
Creates a new public repository for hosting a new GitHub action. This action will allow the currently running job to determine the job name and job ID allowing improved usage of the GitHub API.
A quick overview of the implementation: in order to determine the job ID we need to use the GitHub API to list jobs for a workflow run attempt. In order to determine which job from the API results is the currently running job we need some kind of alternate way of uniquely selecting the job. I looked at the GitHub Actions context information and the only overlap I found was the
runner.name
context which according to the docs may not be unique. Alternatively, I chose to use the job name for the selection criteria which also isn't guaranteed to be unique but typically is and it is reasonable to require users to define unique job name within a user provided workflow. Unfortunately, the job name also isn't available via contexts so to get the job name we need to perform three steps:${{ github.job }}
which is the job YAML key in the workflow to determine the job name template (the job name as defined in YAML can contain GitHub expressions).With these steps we know the name of the job and can use that information to determine the job ID. If a job name happens to not be unique we can detect that and cause the action to fail and request that the user makes the job name unique.
In the future we may choose to use
runner.name
as a first pass in selecting the job from the GitHub API job list. I would consider this an optimization though as we would still need to the job name as either a fallback or as part of the selection criteria.Various issues asking for the job name or ID feature: