Skip to content

Commit

Permalink
feat: add filter-support-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Feb 23, 2021
1 parent c5a5414 commit 7af3f4b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

`2021.02.23`

- feat: add `filter-head-ref`.
- feat: add `filter-head-ref` `filter-support-fork`.

## v1.0.0

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
filter-label: 'check-ci'
filter-creator-authority: 'write'
filter-head-ref: 'master, feature'
filter-support-fork: false
success-review: true
success-review-body: 'LGTM'
success-merge: true
Expand All @@ -44,6 +45,7 @@ jobs:
| filter-creator | Filter PR by creator name. | string | ✖ |
| filter-creator-authority | Filter PR by creator authority. | string | ✖ |
| filter-head-ref | Filter PR head ref branch. | string | ✖ |
| filter-support-fork | Filter PR come from. Default `true`. | boolean | ✖ |
| success-review | Whether to approve when success. | boolean | ✖ |
| success-review-body | Review body. | string | ✖ |
| success-merge | Whether to merge when success. | boolean | ✖ |
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ inputs:
description: Filter PR by creator authority.
filter-head-ref:
description: Filter PR head ref branch.
filter-support-fork:
description: Filter PR come from.
# resule
## success
success-review:
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5977,6 +5977,7 @@ async function run() {
const filterCreator = core.getInput('filter-creator');
const filterCreatorAuthority = core.getInput('filter-creator-authority');
const filterHeadRef = core.getInput('filter-head-ref');
const filterSupportFork = core.getInput('filter-support-fork') || 'true';

const successReview = core.getInput('success-review');
const successReviewBody = core.getInput('success-review-body');
Expand Down Expand Up @@ -6012,7 +6013,12 @@ async function run() {
const onePR = await getOnePR(owner, repo, it.number);
checkPRHeadRef = dealStringToArr(filterHeadRef).includes(onePR.head.ref);
}
if (filterCreatorResult && checkPRType && checkPRHeadRef) {
let checkPRFork = true;
if (filterSupportFork == 'false') {
const onePR = await getOnePR(owner, repo, it.number);
checkPRFork = owner === onePR.head.user.login;
}
if (filterCreatorResult && checkPRType && checkPRHeadRef && checkPRFork) {
if (filterCreatorAuthority) {
const checkAuthResult = await checkAuthority(
owner,
Expand Down
8 changes: 7 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function run() {
const filterCreator = core.getInput('filter-creator');
const filterCreatorAuthority = core.getInput('filter-creator-authority');
const filterHeadRef = core.getInput('filter-head-ref');
const filterSupportFork = core.getInput('filter-support-fork') || 'true';

const successReview = core.getInput('success-review');
const successReviewBody = core.getInput('success-review-body');
Expand Down Expand Up @@ -60,7 +61,12 @@ async function run() {
const onePR = await getOnePR(owner, repo, it.number);
checkPRHeadRef = dealStringToArr(filterHeadRef).includes(onePR.head.ref);
}
if (filterCreatorResult && checkPRType && checkPRHeadRef) {
let checkPRFork = true;
if (filterSupportFork == 'false') {
const onePR = await getOnePR(owner, repo, it.number);
checkPRFork = owner === onePR.head.user.login;
}
if (filterCreatorResult && checkPRType && checkPRHeadRef && checkPRFork) {
if (filterCreatorAuthority) {
const checkAuthResult = await checkAuthority(
owner,
Expand Down

0 comments on commit 7af3f4b

Please sign in to comment.