Skip to content

Commit

Permalink
Perf: Don't run if not on specified branch
Browse files Browse the repository at this point in the history
  • Loading branch information
politician committed Sep 22, 2020
1 parent cf2d6f4 commit e2cd382
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ async function run(): Promise<void> {
const currentRepo = `${context.repo.owner}/${context.repo.repo}`;
core.debug(` Current repo is ${currentRepo}`);

// Detect current branch
const currentBranch = context.ref.replace(/^refs\/heads\//, "");
core.debug(` Current branch is ${currentBranch}`);

// Detect if current repo is SoT or destination
if (currentRepo == destinationRepo) {
if (!context.payload.pull_request) exit(54, "Nothing to do in the destination repo except for Pull Requests.");
Expand All @@ -86,6 +90,7 @@ async function run(): Promise<void> {

// Detect SoT branch if none specified
sotBranch = sotBranch ? sotBranch : await gh.getDefaultBranch(sotRepo);
if (currentBranch != sotBranch) exit(54, `Nothing to do in the SoT repo except on the "${sotBranch}" branch.`);

// Determine destination branch if none specified
destinationBranch = destinationBranch ? destinationBranch : sotBranch;
Expand Down

0 comments on commit e2cd382

Please sign in to comment.