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

Commit

Permalink
✨ Support for protect branch
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Aug 18, 2020
1 parent 008164c commit cd0b605
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: "delete-merged-action"
description: "Automatically delete merged branches (highly configurable)"
author: "Koj <https://github.com/koj.co>"
inputs:
milliseconds:
protectBranches:
required: false
description: "Number of milliseconds to wait"
default: "1000"
description: "Don't delete these branches"
default: "master"
runs:
using: "node12"
main: "dist/index.js"
Expand Down
16 changes: 11 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ export const run = async () => {
*/
if (pullRequest.pull_request.merged) {
try {
await octokit.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: pullRequest.pull_request.base.ref,
});
if (
!(getInput("protectBranches") || "")
.split(",")
.map((branch) => branch.trim())
.includes(pullRequest.pull_request.base.ref)
)
await octokit.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: pullRequest.pull_request.base.ref,
});
} catch (error) {}
}
};
Expand Down

0 comments on commit cd0b605

Please sign in to comment.