Skip to content

Update main branch name used during CI #1288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions build-system/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ function env(key) {
return process.env[key];
}

/**
* Returns true if this is a CI build.
* @return {boolean}
*/
function isCiBuild() {
return !!env('CI');
}

/**
* Returns true if this is a PR build.
* @return {boolean}
Expand All @@ -48,6 +56,7 @@ function isPushBuild() {
}

module.exports = {
isCiBuild,
isPullRequestBuild,
isPushBuild,
};
7 changes: 5 additions & 2 deletions build-system/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
*/

const {getStdout} = require('./exec');
const {isCiBuild} = require('./ci');

/**
* Returns the merge base of the PR branch and the main branch.
* Returns the merge base of the PR branch and the main branch. During CI on
* GH actions, the main branch identifier is "origin/main".
* @return {string}
*/
function gitMergeBaseMain() {
return getStdout(`git merge-base main HEAD`).trim();
const mainBranch = isCiBuild() ? 'origin/main' : 'main';
return getStdout(`git merge-base ${mainBranch} HEAD`).trim();
}

/**
Expand Down