Replies: 1 comment 9 replies
-
There are API endpoints that require this; it's odd how hard it is to retrieve. Agree it should be exposed as an environment variable. Fwiw, here's what we did to get it: name: ${{ join(matrix.*, ' - ') }}
env:
JOB_NAME: ${{ join(matrix.*, ' - ') }}
steps:
- uses: actions/github-script@7a5c598405937d486b0331594b5da2b14db670da # v6
with:
script: |
const assert = (x, ...args) => { if (!x) { throw console.assert(x, ...args) } }
// https://octokit.github.io/rest.js/v18#actions-list-jobs-for-workflow-run-attempt
let jobs = await github.rest.actions.listJobsForWorkflowRunAttempt({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
run_id: context.runId,
attempt_number: process.env.GITHUB_RUN_ATTEMPT,
per_page: 100,
})
assert(jobs.status === 200 && jobs.data)
jobs = jobs.data.jobs
jobs = jobs.filter(job => job.name === process.env.JOB_NAME)
assert(jobs.length === 1)
const job_id = jobs[0].id;
return job_id |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Select Topic Area
Product Feedback
Body
Hello,
Building upon Expose GITHUB_JOB_ID as an environment variable, I would make the case here to the product team to finally give us access to the job id (numerical, e.g.
26515583698
) generated by GitHub when creating a new workflow job.Exposing in workflow definitions
Currently we only get access to the job's Run ID through
${{ github.run_id }}
, but it is not enough in case we want to:Exposing in actions runner
Currently, when using self-hosted runners AFAIK there is absolutely no way to know which specific job is being executed by the runner.
GITHUB_RUN_ID
is currently set, but it would be great if we could also access the job ID. This would help a lot with troubleshooting.Thanks for considering the request, and please let me know if you need further details.
Beta Was this translation helpful? Give feedback.
All reactions