Jim Jimson
Jim Jimson

Reputation: 2528

What is the difference between 'name' and 'id' in Github Actions

In the github action for Google app engine deploy there is a reference to the id in a github action:

- id: Deploy
  uses: google-github-actions/deploy-appengine@main
  with:
    credentials: ${{ secrets.GCP_SA_KEY }}

But the Github Actions examples don't refer to id, rather it refers to the name as the id:

Each job must have an id to associate with the job. The key job_id is a string and its value is a map of the job's configuration data. You must replace <job_id> with a string that is unique to the jobs object. The <job_id> must start with a letter or _ and contain only alphanumeric characters, -, or _.

jobs:
  my_first_job:
    name: My first job
  my_second_job:
    name: My second job

What's the difference?

Upvotes: 18

Views: 16806

Answers (1)

DannyB
DannyB

Reputation: 14776

I believe you are confusing between a step definition, and a job definition.

This is a step:

steps:
- id: deploy
  uses: google-github-actions/deploy-appengine@main
  with:
    credentials: ${{ secrets.gcp_credentials }}

as can be seen in the Usage section of the deploy-appengine repository.

The GitHub Actions workflow syntax documentation is the definitive guide - if you see something written elsewhere that is not mentioned in this guide, it is either a mistake or a misunderstanding.

As for the difference between ID and Name (both in jobs and steps):

  • ID is used as a reference, from other jobs or steps (for example, in jobs.<job_id>.needs).
  • Name is used for display purposes on GitHub.

Finally, for completeness, here are the ID/name related entries in the GitHub workflow syntax:

name: Test                 # <- Workflow name

jobs:
  test:                    # <- Job ID
    name: Run test suite   # <- Optional Job Name

    steps:
    - id:   checkout       # <- Optional step ID
      name: Checkout code  # <- Optional step name

Upvotes: 20

Related Questions