Skip to content

Commit

Permalink
feat: fallback to default branch (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfoley authored Nov 21, 2021
1 parent 4f1581f commit efbb0cb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ignore-team-members | true | Whether to ignore in the case that the PR author is
body-regex | `(fix\|resolv\|clos)(e)*(s\|d)* #\d+` | Regular expression to identify whether the PR body refers to an issue[^2].
body-auto-close | true | Whether or not to auto-close on failed check of PR Body
body-comment | (see [action.yml](./action.yml)) | Comment to leave on PR on failed check of PR Body
protected-branch | "main" | Branch that check should ensure that PR does not use as it's head.
protected-branch | (Blank) | Branch that check should ensure that PR does not use as it's head. If left blank, it falls back to default branch.
protected-branch-auto-close | true | Whether or not to auto-close on failed check of PR head branch
protected-branch-comment | (see [action.yml](./action.yml)) | Comment to leave on PR on failed check of PR head branch.
title-check-enable | true | Whether or not to lint PR title per [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).
Expand Down
16 changes: 9 additions & 7 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.

4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const baseComment = core.getInput('base-comment')
const bodyRegexInput = core.getInput('body-regex')
const bodyAutoClose = core.getBooleanInput('body-auto-close')
const bodyComment = core.getInput('body-comment')
const protectedBranch = core.getInput('protected-branch')
let protectedBranch = core.getInput('protected-branch')
const protectedBranchAutoClose = core.getBooleanInput(
'protected-branch-auto-close'
)
Expand All @@ -26,6 +26,8 @@ async function run(): Promise<void> {
const pr = ctx.issue
const isDraft = (ctx.payload.pull_request?.draft ?? false) === true
const repoOwner = context.repo.owner
if (protectedBranch === '')
protectedBranch = ctx.payload.repository?.default_branch ?? ''
const isClosed =
(ctx.payload.pull_request?.state ?? 'open').toLowerCase() === 'closed'
if (isClosed) {
Expand Down

0 comments on commit efbb0cb

Please sign in to comment.