Skip to content

shawnliujw/slack-approval-guard

Repository files navigation

Slack Approval Guard

With this repo and Slack Approval Citedal you can easily inject the approval process to Gitlab CI/CD pipeline.
To enhance your auto deployment process.

How to use

  1. Ensure you have setup Slack Approval Citedal and get public domain , like http://slack.example.com
  2. Use it in your gitlab-ci:
  • Now this image integrated kubectl already
deploy_prod:
  image: registry.cn-shanghai.aliyuncs.com/shawn_repo/slack-approval-guard
  stage: sample
  script:
    - guard setup $CI_PROJECT_NAME -n $CI_PROJECT_NAMESPACE -e $CI_ENVIRONMENT_NAME -P $CI_PROJECT_URL -p $CI_PIPELINE_ID -b $CI_COMMIT_REF_NAME -a $GITLAB_USER_NAME -c $CI_COMMIT_TITLE -C $CI_COMMIT_SHA -s 'http://slack.example.com/approval'
    - if [ $N -ne 0 ];  then exit ; fi
    - [your other scripts]

Workflow

  1. registry approval with the command above, then the pipeline will show message like below:
    Waiting Approve

  2. then in the configured slack channel, you will see message like below:
    Slack Approval Message

  3. when the assignee click the button, slack will work like below:
    Slack Approved

  4. meanwhile you receive message from step 3, the pipeline will also show message like below:

  • Approved
    Approved

  • Rejected
    Rejected

guard setup 'proejctName' -n 'namespace' -e 'env' -P 'projectURL' -p '$CI_PIPELINE_ID' -b '$CI_COMMIT_REF_NAME' -a '$GITLAB_USER_NAME' -c '$CI_COMMIT_TITLE' -C '$CI_COMMIT_SHA' -s 'http://slack.example.com/approval'