Interview Prep/GitHub Actions/Jobs, Steps, Matrix & Concurrency

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.

All GitHub Actions questions Roadmap: GitHub Actions

More on Jobs, Steps, Matrix & Concurrency