Skip to content

Add deployment approval UI MVC

Andrew Fontaine requested to merge afontaine/deployment-approval into master

What does this MR do and why?

Sets up the ability for users to approve and reject deployments from within the environments page.

Current information shown is how many approvals are needed and how many are done, as well as who has approved and when.

A rejection short cuts to killing the deployment.

This is currently only in the phased out environment UI, but built in a way that it should be easy to drop into the new one.

Screenshots or screen recordings

Screencast_2022-03-07_14_53_04

Screencast_2022-03-07_14_53_55

How to set up and validate locally

  1. Enable runners in your GDK/Gitpod -- see instructions
  2. Enable the new environment table
Feature.enable(:new_environments_table)
  1. Then add the following .gitlab-ci.yml to a project for some deployments:
stages:
    - deploy
    - stop
image: alpine:latest

deploy-prod:
    stage: deploy
    script:
        - sleep 6000
        - echo "deploying prod"
    environment:
        name: production

deploy-staging:
    stage: deploy
    script:
        - echo "deploying staging"
    environment:
        name: staging
        url: https://example.com
    when: manual

deploy-review:
    stage: deploy
    script:
        - echo "Deploying review/$CI_COMMIT_REF_NAME"
    environment:
        name: review/$CI_COMMIT_REF_NAME
        auto_stop_in: 1 week
    only:
        - branches
    except:
        - main


stop_review_app:
  script: stop-review-app
  stage: stop
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    action: stop
  rules:
    - if: $CI_MERGE_REQUEST_ID
      when: manual

Run a pipeline to create the initial environments, then protect the staging environment in Settings > CI/CD.

Run another pipeline, and check the environments page.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

For #342180 (closed)

Edited by Andrew Fontaine

Merge request reports