Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/staging-ci/check-staging-merge.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import { printLog, printError, runMain } from '../lib/executionUtils.ts'
import { command } from '../lib/command.ts'
import { initGitConfig } from '../lib/gitUtils.ts'
import { fetchPR, initGitConfig } from '../lib/gitUtils.ts'

const REPOSITORY = process.env.GIT_REPOSITORY
const CI_COMMIT_SHA = process.env.CI_COMMIT_SHA
const CI_COMMIT_SHORT_SHA = process.env.CI_COMMIT_SHORT_SHA
const CI_COMMIT_REF_NAME = process.env.CI_COMMIT_REF_NAME
const MAIN_BRANCH = process.env.MAIN_BRANCH
const NEXT_MAJOR_BRANCH = process.env.NEXT_MAJOR_BRANCH

runMain(() => {
runMain(async () => {
if (!REPOSITORY || !CI_COMMIT_SHA || !CI_COMMIT_SHORT_SHA || !CI_COMMIT_REF_NAME || !MAIN_BRANCH) {
throw new Error('Missing required environment variables')
}

if (NEXT_MAJOR_BRANCH) {
const pr = await fetchPR(CI_COMMIT_REF_NAME)
if (pr?.base.ref === NEXT_MAJOR_BRANCH) {
printLog(`PR targets ${NEXT_MAJOR_BRANCH}, skipping staging merge check.`)
return
}
}

initGitConfig(REPOSITORY)
command`git fetch --no-tags origin ${MAIN_BRANCH}`.run()
const ciConfigurationFromMain = command`git show origin/${MAIN_BRANCH}:.gitlab-ci.yml`.run()
Expand Down