Skip to content

Commit

Permalink
feat: support "hashedBranches" in deploy-gae
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Dec 3, 2024
1 parent 67cfd43 commit 9204bd3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions resources/backendCfg.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
"type": "array",
"items": { "type": "string" }
},
"hashedBranches": {
"type": "boolean"
},
"appYamlPassEnv": { "type": "string" }
},
"required": ["gaeProject", "gaeService", "appEnvDefault"]
Expand Down
5 changes: 5 additions & 0 deletions src/deploy/backend.cfg.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export interface BackendCfg {
*/
branchesWithTimestampVersions?: string[]

/**
* If true - branch names are not passed into deployed urls as is, but are hashed.
*/
hashedBranches?: boolean

/**
* Comma-separated list of env variables that will be passed to app.yaml from process.env
*/
Expand Down
11 changes: 9 additions & 2 deletions src/deploy/deploy.util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { _assert, _mapValues, _merge, _truncate, localTime } from '@naturalcycles/js-lib'
import { dimGrey, fs2, white } from '@naturalcycles/nodejs-lib'
import { dimGrey, fs2, md5, white } from '@naturalcycles/nodejs-lib'
import { BackendCfg } from './backend.cfg.util'
import { AppYaml, DeployInfo } from './deploy.model'

Expand Down Expand Up @@ -57,7 +57,14 @@ export async function createDeployInfo(
if (gaeServiceByBranch[gitBranch]) {
gaeService = validateGAEServiceName(gaeServiceByBranch[gitBranch])
} else {
gaeService = validateGAEServiceName([gitBranch, gaeService].join('--'))
let branchName = gitBranch

if (backendCfg.hashedBranches) {
// todo: jira
branchName = md5(gitBranch).slice(0, 10)
}

gaeService = validateGAEServiceName([branchName, gaeService].join('--'))
}

let gaeVersion = '1'
Expand Down
2 changes: 2 additions & 0 deletions src/test/project/backend.cfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ gaeService: test-service

appEnvDefault: prod
appYamlPassEnv: AA,BB

hashedBranches: true

0 comments on commit 9204bd3

Please sign in to comment.