The “github.job” is the key of a job object defined in the workflow definition (workflow file). It is fixed and not changed between workflow runs, unless you change it in the workflow file. The key also can be used as the job name in each workflow run, if you do not specify a name for the job.
In the Workflow Jobs API, the job here refers to an instance of the job object, the instance is generated within a workflow run (an instance of the workflow definition).
So, the job_id in the API is an unique number for each job instance within a repository.
If you view the title of the each Workflow Jobs API, you can find that all of them are “xxx for a workflow run” rather than “xxx for a workflow”.
Problem is that in Github Actions there seems to be no way to get the integer job ID value.
Yes, there is no any easy, fast way to get the integer job ID.
- If you do not specify job name, as I mentioned above, generally the key of the job object you defined in the workflow file will be used as the name of the job instance in each workflow run.
So, to get the integer job ID, here is workaround:
- Using “github.job” to get the key, also is name of the job instance.
- Execute the “List jobs for a workflow run” API.
- From the response context of the API, find the job via the name, then you can get the integer job ID from it.
- However, if you have specify the job name with another string, above workaround is not work. It is difficult to get the integer job ID. We seem have not available method to do this.
I recommend that you can directly report a feature request here to ask adding more useful properties (such as name and id) of the job instance in the job context or the github context.
That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.