Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

Commit

Permalink
🐛 Use head branch, not base
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Sep 26, 2020
1 parent 3d50502 commit 10c6b2b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ export const run = async () => {

const pullRequest = (context as any).payload
.pull_request as EventPayloads.WebhookPayloadPullRequestPullRequest;
const branchName = pullRequest.head.ref;

console.log("Branches to delete are", getInput("branches"));
console.log("This branch is", pullRequest.base.ref);
console.log("This branch is", branchName);

const pullRequestInfo = await octokit.pulls.get({
owner: context.repo.owner,
Expand All @@ -30,22 +31,22 @@ export const run = async () => {
console.log("Is this PR merged?", pullRequestInfo.data.merged);
console.log(
"Should we delete this branch?",
shouldMerge(pullRequest.base.ref, getInput("branches"))
shouldMerge(branchName, getInput("branches"))
);

/**
* Pull request has been merged
*/
if (
pullRequestInfo.data.merged &&
shouldMerge(pullRequest.base.ref, getInput("branches"))
shouldMerge(branchName, getInput("branches"))
) {
console.log("Proceeding to delete branch");
try {
await octokit.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: pullRequest.base.ref,
ref: branchName,
});
console.log("Deleted branch");
} catch (error) {
Expand Down

0 comments on commit 10c6b2b

Please sign in to comment.