GitHub Actions two jobs with the same id
Two jobs declared under the same id collide. YAML duplicate keys mean the second silently overrides the first or the file is rejected.
What this error means
The workflow is rejected for a duplicate key, or one job mysteriously disappears because its id was reused.
github-actions
Invalid workflow file: .github/workflows/ci.yml#L15
duplicate key 'build' in mappingCommon causes
Copy-pasted job not renamed
Duplicating a job block and forgetting to change its id reuses the key.
Merge brought in a same-named job
A merge can introduce a second job with an existing id.
How to fix it
Give each job a unique id
- Rename the duplicate to a distinct id.
- Update any needs references to the new id.
.github/workflows/ci.yml
jobs:
build-linux: { runs-on: ubuntu-latest, steps: [{ run: make }] }
build-mac: { runs-on: macos-latest, steps: [{ run: make }] }How to prevent it
- Run a YAML linter that flags duplicate keys.
- Use descriptive, unique job ids.
Frequently asked questions
What causes "two jobs with the same id"?
Duplicating a job block and forgetting to change its id reuses the key.
How do I fix two jobs with the same id?
Give each job a unique id
Related guides
GitHub Actions "The identifier is invalid" for a job idFix the GitHub Actions "The identifier is invalid" error caused by a job id that starts with a number or cont…
GitHub Actions "needs job X but it is not defined"Fix the GitHub Actions error where a job needs another job that is not defined, usually a typo in the job id…
GitHub Actions YAML "did not find expected key"Fix the GitHub Actions YAML error "did not find expected key" caused by broken indentation that leaves the pa…