1+ import { parseArgs } from 'node:util'
12import { printLog , runMain , timeout } from '../lib/executionUtils.ts'
23import { command } from '../lib/command.ts'
4+ import { siteByDatacenter } from '../lib/datacenter.ts'
35
46/**
57 * Orchestrate the deployments of the artifacts for specific DCs
@@ -10,19 +12,35 @@ const ONE_MINUTE_IN_SECOND = 60
1012const GATE_DURATION = 30 * ONE_MINUTE_IN_SECOND
1113const GATE_INTERVAL = ONE_MINUTE_IN_SECOND
1214
13- const version : string = process . argv [ 2 ]
14- const uploadPath : string = process . argv [ 3 ]
15- const withMonitorChecks : boolean = process . argv [ 4 ] === 'true'
15+ const {
16+ values : { 'check-monitors' : checkMonitors } ,
17+ positionals,
18+ } = parseArgs ( {
19+ allowPositionals : true ,
20+ allowNegative : true ,
21+ options : {
22+ 'check-monitors' : {
23+ type : 'boolean' ,
24+ } ,
25+ } ,
26+ } )
27+
28+ const version = positionals [ 0 ]
29+ const uploadPath = positionals [ 1 ] === 'minor-dcs' ? getAllMinorDcs ( ) . join ( ',' ) : positionals [ 1 ]
30+
31+ if ( ! uploadPath ) {
32+ throw new Error ( 'UPLOAD_PATH argument is required' )
33+ }
1634
1735runMain ( async ( ) => {
18- if ( withMonitorChecks ) {
36+ if ( checkMonitors ) {
1937 command `node ./scripts/deploy/check-monitors.ts ${ uploadPath } ` . withLogs ( ) . run ( )
2038 }
2139
2240 command `node ./scripts/deploy/deploy.ts prod ${ version } ${ uploadPath } ` . withLogs ( ) . run ( )
2341 command `node ./scripts/deploy/upload-source-maps.ts ${ version } ${ uploadPath } ` . withLogs ( ) . run ( )
2442
25- if ( withMonitorChecks && uploadPath !== 'root' ) {
43+ if ( checkMonitors && uploadPath !== 'root' ) {
2644 await gateMonitors ( uploadPath )
2745 }
2846} )
@@ -36,3 +54,12 @@ async function gateMonitors(uploadPath: string): Promise<void> {
3654 }
3755 printLog ( ) // new line
3856}
57+
58+ // Major DCs are the ones that are deployed last.
59+ // They have their own step jobs in `deploy-manual.yml` and `deploy-auto.yml`.
60+ const MAJOR_DCS = [ 'root' , 'us1' , 'eu1' ]
61+
62+ // Minor DCs are all the DCs from `siteByDatacenter` that are not in `MAJOR_DCS`.
63+ function getAllMinorDcs ( ) : string [ ] {
64+ return Object . keys ( siteByDatacenter ) . filter ( ( dc ) => ! MAJOR_DCS . includes ( dc ) )
65+ }
0 commit comments