Interview Prep/Ansible/Testing, CI/CD and Quality

How do you protect production deploy jobs in GitHub Actions or GitLab CI?

IntermediateProductionTesting, CI/CD and Quality
Answer
  • Put the prod job behind a protected environment with required reviewers (GitHub) or a when: manual job on a protected branch with protected environment approvals (GitLab).
  • Only the prod environment holds prod secrets or can assume the prod OIDC role.
  • Require the same commit to have passed lint, Molecule and the staging deploy first (needs: chains).
  • Show the --check --diff output for prod in the approval step so the approver sees what will change.
  • Use concurrency (GitHub) or resource_group (GitLab) so two prod runs never overlap.
deploy-prod:
  needs: [deploy-staging]
  environment: production
  concurrency: ansible-prod

The goal is that nobody, including admins, can push to main and have it reach prod unreviewed.

All Ansible questions Roadmap: Ansible

More on Testing, CI/CD and Quality