Interview Prep/CI/CD/GitHub Actions and GitLab CI in Production

How do you do a safe production deploy with approval in GitLab?

BeginnerProductionGitHub Actions and GitLab CI in Production
Answer

Make the production job manual, tied to a protected environment with an approval rule (for example two approvers from the release group, with committer approval prevented), and restrict it to protected branches or tags. Add resource_group: production, then run a smoke test job that triggers a rollback job on failure.

deploy-prod:
  stage: deploy
  script: ./deploy.sh production $CI_COMMIT_SHA
  environment: production
  resource_group: production
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: manual
All CI/CD questions Roadmap: GitLab CI/CD

More on GitHub Actions and GitLab CI in Production