Skip to content

Commit

Permalink
✨split release deployment into manual or auto
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Apr 22, 2024
1 parent 6883600 commit 6e0cc17
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 82 deletions.
90 changes: 8 additions & 82 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ stages:
- after-tests
- browserstack
- pre-deploy
- pre-deploy-notify
- deploy:canary
- notify:canary
- deploy
Expand Down Expand Up @@ -306,67 +305,21 @@ deploy-prod-canary:
- node ./scripts/deploy/deploy.js prod canary root
- node ./scripts/deploy/upload-source-maps.js canary root

.deploy-prod:
deploy-manual:
stage: deploy
extends:
- .base-configuration
- .tags
when: manual
allow_failure: false
script:
- export BUILD_MODE=release
- VERSION=$(node -p -e "require('./lerna.json').version")
- yarn
- yarn build:bundle
- node ./scripts/deploy/check-monitors.js $UPLOAD_PATH
- node ./scripts/deploy/deploy.js prod v${VERSION%%.*} $UPLOAD_PATH
- node ./scripts/deploy/upload-source-maps.js v${VERSION%%.*} $UPLOAD_PATH

step-1_deploy-prod-minor-dcs:
extends:
- .deploy-prod
variables:
UPLOAD_PATH: us3,us5,ap1

step-2_deploy-prod-eu1:
extends:
- .deploy-prod
variables:
UPLOAD_PATH: eu1

step-3_deploy-prod-us1:
extends:
- .deploy-prod
variables:
UPLOAD_PATH: us1

step-4_deploy-prod-gov:
extends:
- .deploy-prod
variables:
UPLOAD_PATH: root

step-5_publish-npm:
stage: deploy
extends:
- .base-configuration
- .tags
when: manual
allow_failure: false
script:
- yarn
- node ./scripts/deploy/publish-npm.js
trigger:
include:
- local: .gitlab/deploy-manual.yml

step-6_publish-developer-extension:
deploy-auto:
stage: deploy
extends:
- .base-configuration
- .tags
when: manual
allow_failure: false
script:
- yarn
- node ./scripts/deploy/publish-developer-extension.js
trigger:
include:
- local: .gitlab/deploy-auto.yml

########################################################################################################################
# Notify
Expand Down Expand Up @@ -395,15 +348,6 @@ notify-staging-failure:
- 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME main pipeline for <$BUILD_URL|$COMMIT_MESSAGE> failed."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"

notify-release-ready:
stage: pre-deploy-notify
extends:
- .prepare_notification
- .tags
script:
- 'MESSAGE_TEXT=":i: $CI_PROJECT_NAME <$BUILD_URL|$COMMIT_MESSAGE> ready to be deployed to :datadog:"'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"

notify-prod-canary-success:
stage: notify:canary
extends:
Expand All @@ -424,24 +368,6 @@ notify-prod-canary-failure:
- 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME release pipeline <$BUILD_URL|$COMMIT_MESSAGE> failed."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"

notify-prod-stable-success:
extends:
- .prepare_notification
- .tags
script:
- 'MESSAGE_TEXT=":rocket: $CI_PROJECT_NAME <$COMMIT_URL|$COMMIT_MESSAGE> deployed to :earth_americas:."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"
- postmessage "#rum-browser-sdk-ops" "$MESSAGE_TEXT"

notify-prod-stable-failure:
extends:
- .prepare_notification
- .tags
when: on_failure
script:
- 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME release pipeline <$BUILD_URL|$COMMIT_MESSAGE> failed."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"

########################################################################################################################
# To staging CI
########################################################################################################################
Expand Down
60 changes: 60 additions & 0 deletions .gitlab/deploy-auto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
stages:
- pre-notify
- deploy
- post-notify

.base-configuration:
tags: ['runner:main', 'size:large']
image: $CI_IMAGE

deploy-auto:
stage: deploy
extends:
- .base-configuration
when: manual
allow_failure: false
script:
- export BUILD_MODE=release
- VERSION=$(node -p -e "require('./lerna.json').version")
- yarn
- yarn build:bundle
- node ./scripts/deploy-auto.js v${VERSION%%.*}

########################################################################################################################
# Notify
########################################################################################################################

include: 'https://gitlab-templates.ddbuild.io/slack-notifier/v1/template.yml'

.prepare_notification:
extends: .slack-notifier-base
before_script:
- COMMIT_MESSAGE=`git show-branch --no-name HEAD`
- BUILD_URL="$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID"
- COMMIT_URL="$CI_PROJECT_URL/commits/$CI_COMMIT_SHA"

notify-deploy-ready:
stage: pre-notify
extends:
- .prepare_notification
script:
- 'MESSAGE_TEXT=":i: $CI_PROJECT_NAME <$BUILD_URL|$COMMIT_MESSAGE> ready to be deployed *automatically* to :datadog:"'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"

notify-deploy-success:
stage: post-notify
extends:
- .prepare_notification
script:
- 'MESSAGE_TEXT=":rocket: $CI_PROJECT_NAME <$COMMIT_URL|$COMMIT_MESSAGE> *automatically* deployed to :earth_americas:."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"
- postmessage "#rum-browser-sdk-ops" "$MESSAGE_TEXT"

notify-deploy-failure:
stage: post-notify
extends:
- .prepare_notification
when: on_failure
script:
- 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME *automatic* deployment of <$BUILD_URL|$COMMIT_MESSAGE> failed."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"
108 changes: 108 additions & 0 deletions .gitlab/deploy-manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
stages:
- pre-notify
- deploy
- post-notify

.base-configuration:
tags: ['runner:main', 'size:large']
image: $CI_IMAGE

.deploy-prod:
stage: deploy
when: manual
allow_failure: false
script:
- export BUILD_MODE=release
- VERSION=$(node -p -e "require('./lerna.json').version")
- yarn
- yarn build:bundle
- node ./scripts/deploy/check-monitors.js $UPLOAD_PATH
- node ./scripts/deploy/deploy.js prod v${VERSION%%.*} $UPLOAD_PATH
- node ./scripts/deploy/upload-source-maps.js v${VERSION%%.*} $UPLOAD_PATH

step-1_deploy-prod-minor-dcs:
extends:
- .base-configuration
- .deploy-prod
variables:
UPLOAD_PATH: us3,us5,ap1

step-2_deploy-prod-eu1:
extends:
- .base-configuration
- .deploy-prod
variables:
UPLOAD_PATH: eu1

step-3_deploy-prod-us1:
extends:
- .base-configuration
- .deploy-prod
variables:
UPLOAD_PATH: us1

step-4_deploy-prod-gov:
extends:
- .base-configuration
- .deploy-prod
variables:
UPLOAD_PATH: root

step-5_publish-npm:
stage: deploy
extends:
- .base-configuration
when: manual
allow_failure: false
script:
- yarn
- node ./scripts/deploy/publish-npm.js

step-6_publish-developer-extension:
stage: deploy
extends:
- .base-configuration
when: manual
allow_failure: false
script:
- yarn
- node ./scripts/deploy/publish-developer-extension.js

########################################################################################################################
# Notify
########################################################################################################################

include: 'https://gitlab-templates.ddbuild.io/slack-notifier/v1/template.yml'

.prepare_notification:
extends: .slack-notifier-base
before_script:
- COMMIT_MESSAGE=`git show-branch --no-name HEAD`
- BUILD_URL="$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID"
- COMMIT_URL="$CI_PROJECT_URL/commits/$CI_COMMIT_SHA"

notify-deploy-ready:
stage: pre-notify
extends:
- .prepare_notification
script:
- 'MESSAGE_TEXT=":i: $CI_PROJECT_NAME <$BUILD_URL|$COMMIT_MESSAGE> ready to be deployed *manually* to :datadog:"'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"

notify-deploy-success:
stage: post-notify
extends:
- .prepare_notification
script:
- 'MESSAGE_TEXT=":rocket: $CI_PROJECT_NAME <$COMMIT_URL|$COMMIT_MESSAGE> *manually* deployed to :earth_americas:."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"
- postmessage "#rum-browser-sdk-ops" "$MESSAGE_TEXT"

notify-deploy-failure:
stage: post-notify
extends:
- .prepare_notification
when: on_failure
script:
- 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME *manual* deployment of <$BUILD_URL|$COMMIT_MESSAGE> failed."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"

0 comments on commit 6e0cc17

Please sign in to comment.