Skip to content

Commit 6b40ce2

Browse files
authored
feat: support skip-contribution-count (#31)
* feat: support skip-count * fix
1 parent 97061cb commit 6b40ce2

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
| skip-verify-authority | Skip verify by creator authority. Option: `read` `write` `admin` | string | ✖ |
4444
| skip-verify-users | Skip verify by creator userid. Support multiple | string | ✖ |
4545
| skip-label | Skip label | string | ✖ |
46+
| skip-contribution-count | Skip verify by commit count | number | ✖ |
4647
| comment | Comment when verification success | string | ✖ |
4748
| comment-mark | Comment mark to find. | string | ✖ |
4849
| assignees | Assignees when verification success | string | ✖ |

action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ inputs:
1818
description: Skip verify by github userid.
1919
skip-label:
2020
description: Skip verify by pr label.
21+
skip-contribution-count:
22+
description: Skip verify by commits count.
2123
forbid-files:
2224
description: Forbid files. Higher than allowed.
2325
forbid-paths:
@@ -38,5 +40,5 @@ inputs:
3840
description: When hit, whether set failed.
3941

4042
runs:
41-
using: 'node12'
43+
using: 'node20'
4244
main: 'dist/index.js'

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
"dependencies": {
1919
"@actions/core": "^1.2.6",
2020
"@actions/github": "^4.0.0",
21-
"@octokit/rest": "^18.0.14",
21+
"@octokit/rest": "^22.0.0",
2222
"actions-util": "^1.0.0"
2323
},
2424
"devDependencies": {
2525
"@umijs/fabric": "^2.5.6",
26-
"@vercel/ncc": "^0.27.0",
26+
"@vercel/ncc": "0.34.0",
2727
"prettier": "^2.2.1"
2828
}
2929
}

src/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ async function run() {
2727
const skipVerifyUsers = core.getInput('skip-verify-users');
2828
const skipLabel = core.getInput('skip-label');
2929
const setFailedInput = core.getInput('set-failed');
30+
const skipContributionCount = core.getInput('skip-contribution-count');
3031

3132
if (skipLabel && labels && labels.length) {
3233
const labelsName = labels.map(({ name }) => name);
@@ -78,12 +79,28 @@ async function run() {
7879
return out;
7980
}
8081

82+
async function checkCommitsCount() {
83+
const res = await octokit.repos.listCommits({
84+
owner,
85+
repo,
86+
author: creator,
87+
per_page: skipContributionCount,
88+
});
89+
const out = res.data.length >= skipContributionCount;
90+
core.info(`The user ${creator} check commits count ${out}!`);
91+
return out;
92+
}
93+
8194
let result = false;
8295

8396
if (skipVerifyAuthority) {
8497
result = await checkAuthority();
8598
}
8699

100+
if (!result && skipContributionCount) {
101+
result = await checkCommitsCount();
102+
}
103+
87104
if (!result) {
88105
const changeFiles = await getFiles();
89106
if (changeFiles.length == 0) {

0 commit comments

Comments
 (0)