Tiryoh/gha-jobid-action

document what "job_name" is

leemeador opened this issue · 2 comments

The docs just say to supply the "job_name" and this causes some confusion:

Imagine this workflow:

name: Test Something
on:
  workflow_dispatch:

jobs:
  build:
    name: Test that this build Works
    runs-on: ubuntu-latest
    steps:
      - name: Show the context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: |
          echo "$GITHUB_CONTEXT"

The "job_name" must be " Test that this build Work" which comes from jobs.build.name in the yaml and not "build" itself, which in the context is github.job. There is nothing in the context to supply the job_name in this case.

I haven't tried it but I suspect github.job can be used if there is no name field in the job entry in the yaml.

Hi @leemeador, Thanks for pointing it out.

It looks like github.job was added at some point.
https://stackoverflow.com/questions/61611978/get-current-job-name-in-github-actions-workflow

How about this? Please feel free to left some review comments.
#23

preview url: https://github.com/Tiryoh/gha-jobid-action/tree/feature/update-readme

Merged #23.
If you have further comments, please re-open this issue.