Skip to content

Commit

Permalink
👷 Bump chrome version refine notifications (#1620)
Browse files Browse the repository at this point in the history
* Check if bump branch already exists

* Only notify when PR created
  • Loading branch information
amortemousque authored Jul 5, 2022
1 parent 13dc814 commit e54d0f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
11 changes: 10 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,22 @@ bump-chrome-version-scheduled:
- eval $(ssh-agent -s)
script:
- node scripts/bump-chrome-driver-version.js
artifacts:
reports:
dotenv: build.env

bump-chrome-version-scheduled-success:
extends: .prepare_notification
only:
variables:
- $TARGET_TASK_NAME == "bump-chrome-version-scheduled"
before_script:
- '[ -z "$BUMP_CHROME_PULL_REQUEST_URL" ] && exit'
script:
- 'MESSAGE_TEXT=":chrome: [*$CI_PROJECT_NAME*] New Chrome version available on <https://github.com/DataDog/browser-sdk/pulls|PRs>."'
- 'MESSAGE_TEXT=":chrome: [*$CI_PROJECT_NAME*] New Chrome version available on <$BUMP_CHROME_PULL_REQUEST_URL|PR>."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"
dependencies:
- bump-chrome-version-scheduled

bump-chrome-version-scheduled-failure:
extends: .prepare_notification
Expand All @@ -453,3 +460,5 @@ bump-chrome-version-scheduled-failure:
script:
- 'MESSAGE_TEXT=":x: [*$CI_PROJECT_NAME*] Chrome version bumped failed on pipeline <$BUILD_URL|$COMMIT_MESSAGE>."'
- postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"
dependencies:
- bump-chrome-version-scheduled
17 changes: 14 additions & 3 deletions scripts/bump-chrome-driver-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ async function main() {

if (majorPackageVersion !== getMajor(driverVersion)) {
printError(`No driver available for chrome ${packageVersion}.`)
process.exit(1)
process.exit()
}

const chromeVersionBranch = `bump-chrome-version-to-${driverVersion}`
const commitMessage = `👷 Bump chrome to ${packageVersion}`

const isBranchAlreadyCreated = await executeCommand(`git ls-remote --heads ${REPOSITORY} ${chromeVersionBranch}`)
if (isBranchAlreadyCreated) {
printLog('Bump chrome branch already created.')
process.exit()
}

await executeCommand(`git checkout -b ${chromeVersionBranch}`)

printLog('Update versions...')
Expand All @@ -55,9 +62,12 @@ async function main() {
await executeCommand(`git push origin ${chromeVersionBranch}`)

printLog('Create PR...')
await createPullRequest()

const pullRequestUrl = await createPullRequest()
printLog(`Chrome version bump PR created (from ${CURRENT_PACKAGE_VERSION} to ${packageVersion}).`)

// used to share the pull request url to the notification jobs
await executeCommand(`echo "BUMP_CHROME_PULL_REQUEST_URL=${pullRequestUrl}" >> build.env`)
}

async function getPackageVersion() {
Expand Down Expand Up @@ -85,7 +95,8 @@ function getMajor(version) {
async function createPullRequest() {
const githubAccessToken = await getSecretKey('ci.browser-sdk.github_access_token')
await executeCommand(`echo "${githubAccessToken}" | gh auth login --with-token`)
await executeCommand(`gh pr create --fill --base ${MAIN_BRANCH}`)
const pullRequestUrl = await executeCommand(`gh pr create --fill --base ${MAIN_BRANCH}`)
return pullRequestUrl.trim()
}

main().catch(logAndExit)

0 comments on commit e54d0f8

Please sign in to comment.