What is `jobs.<id>.environment` beyond approvals, and how do you set a deployment URL?
IntermediateConceptJobs, Steps, Matrix & Concurrency
Answer
Naming an environment creates a GitHub deployment record, applies protection rules, exposes environment secrets and variables to the job, and changes the OIDC sub claim to repo:ORG/REPO:environment:NAME.
deploy:
environment:
name: staging
url: ${{ steps.out.outputs.url }}
The URL appears on the PR and the environments page. The environment name can be an expression, which is how one reusable workflow serves dev, staging and prod.
More on Jobs, Steps, Matrix & Concurrency
How does `needs` work, and what happens to a job whose dependency failed or was skipped?BeginnerWhat is the implicit `success()` in a job `if`, and why is `always()` usually the wrong fix?IntermediateWhat values can `needs.<job>.result` take?BeginnerHow does a matrix expand, and how are job names generated?BeginnerHow do `include` and `exclude` work in a matrix?IntermediateWhat do `fail-fast` and `max-parallel` do?Beginner