Deployments to production need a manual approval and only the main branch may deploy.
IntermediateScenarioGitHub Actions
Answer
Situation read → Environment protection rules.
What I'd do →
- Create a
productionenvironment with required reviewers and a deployment branch rule limited tomain. - Reference it:
jobs.deploy.environment: production. - Store prod secrets as environment secrets, so they are released only after approval.
Why → Secrets and approvals are enforced by the platform, not by workflow code a PR could change.
Interview tip → Note that environment secrets are not available to jobs that do not target that environment.
More on GitHub Actions
What are workflows, jobs, steps and actions in GitHub Actions?BeginnerWhat events can trigger a workflow?BeginnerWhat is the difference between `pull_request` and `pull_request_target`?AdvancedWhat is a runner, and how do GitHub-hosted and self-hosted runners differ?BeginnerHow do you pass data between steps and between jobs?IntermediateHow does a build matrix work?Intermediate