Interview Prep/GitHub Actions/Secrets, Variables, Environments & Permissions

How do environments relate to GitHub Deployments and the deployments API?

AdvancedConceptSecrets, Variables, Environments & Permissions
Answer

Every job with environment creates a deployment object for that environment and ref, and updates deployment statuses (in_progress, success, failure) automatically. The environments page and PR timeline show history ("deployed to staging 2 hours ago"), and the API (GET /repos/{owner}/{repo}/deployments?environment=prod) lets tooling find what SHA is in prod. A side effect: jobs that use an environment only to read its secrets still create deployment records, which clutters the history, so give such jobs a separate environment name (for example prod-readonly).

All GitHub Actions questions Roadmap: GitHub Actions

More on Secrets, Variables, Environments & Permissions