-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 Introduce a way to automate the release deployment (#2720)
* ✨ add an option to display command logs * ✨introduce deploy-auto script * ✨split release deployment into manual or auto * 👌 develop deploy-auto script into gitlab jobs * 👌 remove unnecessary manual steps
- Loading branch information
Showing
5 changed files
with
273 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
stages: | ||
- pre-notify | ||
- deploy | ||
- post-notify | ||
|
||
.base-configuration: | ||
tags: ['runner:main', 'size:large'] | ||
image: $CI_IMAGE | ||
|
||
.deploy-prod: | ||
stage: deploy | ||
script: | ||
- export BUILD_MODE=release | ||
- VERSION=$(node -p -e "require('./lerna.json').version") | ||
- yarn | ||
- yarn build:bundle | ||
- node ./scripts/deploy/deploy-prod-dc.js v${VERSION%%.*} $UPLOAD_PATH true | ||
|
||
step-1_deploy-prod-minor-dcs: | ||
when: manual | ||
allow_failure: false | ||
extends: | ||
- .base-configuration | ||
- .deploy-prod | ||
variables: | ||
UPLOAD_PATH: us3,us5,ap1 | ||
|
||
step-2_deploy-prod-eu1: | ||
needs: | ||
- step-1_deploy-prod-minor-dcs | ||
extends: | ||
- .base-configuration | ||
- .deploy-prod | ||
variables: | ||
UPLOAD_PATH: eu1 | ||
|
||
step-3_deploy-prod-us1: | ||
needs: | ||
- step-2_deploy-prod-eu1 | ||
extends: | ||
- .base-configuration | ||
- .deploy-prod | ||
variables: | ||
UPLOAD_PATH: us1 | ||
|
||
step-4_deploy-prod-gov: | ||
needs: | ||
- step-3_deploy-prod-us1 | ||
extends: | ||
- .base-configuration | ||
- .deploy-prod | ||
variables: | ||
UPLOAD_PATH: root | ||
|
||
step-5_publish-npm: | ||
needs: | ||
- step-4_deploy-prod-gov | ||
stage: deploy | ||
extends: | ||
- .base-configuration | ||
allow_failure: false | ||
script: | ||
- yarn | ||
- node ./scripts/deploy/publish-npm.js | ||
|
||
step-6_publish-developer-extension: | ||
needs: | ||
- step-5_publish-npm | ||
stage: deploy | ||
extends: | ||
- .base-configuration | ||
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 *automatically* to :datadog:"' | ||
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" | ||
|
||
notify-deploy-success: | ||
stage: post-notify | ||
needs: | ||
- step-6_publish-developer-extension | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
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/deploy-prod-dc.js v${VERSION%%.*} $UPLOAD_PATH false | ||
|
||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { printLog, runMain, timeout } = require('../lib/execution-utils') | ||
const { command } = require('../lib/command') | ||
|
||
/** | ||
* Orchestrate the deployments of the artifacts for specific DCs | ||
* Usage: | ||
* node deploy-prod-dc.js vXXX us1,eu1,... true|false | ||
*/ | ||
const ONE_MINUTE_IN_SECOND = 60 | ||
const GATE_DURATION = 30 * ONE_MINUTE_IN_SECOND | ||
const GATE_INTERVAL = ONE_MINUTE_IN_SECOND | ||
|
||
const version = process.argv[2] | ||
const uploadPath = process.argv[3] | ||
const withGateMonitors = process.argv[4] === 'true' | ||
|
||
runMain(async () => { | ||
command`node ./scripts/deploy/check-monitors.js ${uploadPath}`.withLogs().run() | ||
command`node ./scripts/deploy/deploy.js prod v${version} ${uploadPath}`.withLogs().run() | ||
command`node ./scripts/deploy/upload-source-maps.js prod v${version} ${uploadPath}`.withLogs().run() | ||
|
||
if (withGateMonitors && uploadPath !== 'root') { | ||
await gateMonitors(uploadPath) | ||
} | ||
}) | ||
|
||
async function gateMonitors(uploadPath) { | ||
printLog(`Check monitors for ${uploadPath} during ${GATE_DURATION / ONE_MINUTE_IN_SECOND} minutes`) | ||
for (let i = 0; i < GATE_DURATION; i += GATE_INTERVAL) { | ||
command`node ./scripts/deploy/check-monitors.js ${uploadPath}`.run() | ||
process.stdout.write('.') // progress indicator | ||
await timeout(GATE_INTERVAL * 1000) | ||
} | ||
printLog() // new line | ||
} |
Oops, something went wrong.