Skip to content

Commit

Permalink
Get PR base branch from context
Browse files Browse the repository at this point in the history
  • Loading branch information
djun-kim committed Oct 3, 2019
1 parent 0b7031f commit a598a67
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ async function run() {
return;
}

const prBase = getPrBase();
if (!prBase) {
console.log('Could not get pull request base branch from context, exiting');
return;
}
else {
core.debug(`Base branch is #${prBase}`);
}

const client = new github.GitHub(token);

core.debug(`fetching changed files for pr #${prNumber}`);
Expand Down Expand Up @@ -49,6 +58,15 @@ function getPrNumber(): number | undefined {
return pullRequest.number;
}

function getPrBase(): string[] | undefined {
const pullRequest = github.context.payload.pull_request;
if (!pullRequest) {
return undefined;
}

return pullRequest.base.ref;
}

async function getChangedFiles(
client: github.GitHub,
prNumber: number
Expand Down

0 comments on commit a598a67

Please sign in to comment.