Skip to content

Commit d192707

Browse files
ryancheleytim-schilling
authored andcommitted
added bot check gha
1 parent 26ba136 commit d192707

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Member Verification Check
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
jobs:
8+
verify-new-member:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: write
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Check PR title format
18+
id: check-title
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const title = context.payload.pull_request.title;
23+
if (!title.startsWith('[MEMBER]')) {
24+
console.log('PR title does not start with [MEMBER], skipping verification check');
25+
return 'skip';
26+
}
27+
return 'continue';
28+
29+
- name: Check user account age
30+
if: steps.check-title.outputs.result == 'continue'
31+
id: check-user
32+
uses: actions/github-script@v7
33+
env:
34+
MIN_ACCOUNT_AGE_MONTHS: ${{ vars.MIN_ACCOUNT_AGE_MONTHS || '3' }} # Default to 3 months if not set
35+
with:
36+
script: |
37+
const creator = context.payload.pull_request.user.login;
38+
const response = await github.rest.users.getByUsername({
39+
username: creator
40+
});
41+
42+
const createdAt = new Date(response.data.created_at);
43+
const now = new Date();
44+
const accountAgeInMonths = (now - createdAt) / (1000 * 60 * 60 * 24 * 30);
45+
const minAgeMonths = parseInt(process.env.MIN_ACCOUNT_AGE_MONTHS);
46+
47+
console.log(`Account age in months: ${accountAgeInMonths}`);
48+
console.log(`Required minimum age in months: ${minAgeMonths}`);
49+
50+
if (accountAgeInMonths < minAgeMonths) {
51+
const message = [
52+
`👋 Hello @${creator}!`,
53+
'',
54+
`Thank you for your interest in joining our organization. We noticed that your GitHub account is less than ${minAgeMonths} months old.`,
55+
'',
56+
'To help us verify that you\'re a real person and maintain the security of our organization, please provide one of the following:',
57+
'- A link to your LinkedIn profile',
58+
'- Links to your other social media presence',
59+
'- Any other form of verification that shows you\'re a real person',
60+
'',
61+
'Please provide this information in a comment on this PR.',
62+
'',
63+
'Note: This is an automated message to help prevent bot accounts from joining our organization.'
64+
].join('\n');
65+
66+
await github.rest.issues.createComment({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
issue_number: context.issue.number,
70+
body: message
71+
});
72+
73+
return 'new-account';
74+
}
75+
76+
return 'existing-account';
77+
78+
- name: Add label if new account
79+
if: steps.check-user.outputs.result == 'new-account' && steps.check-title.outputs.result == 'continue'
80+
uses: actions/github-script@v7
81+
with:
82+
script: |
83+
await github.rest.issues.addLabels({
84+
owner: context.repo.owner,
85+
repo: context.repo.repo,
86+
issue_number: context.issue.number,
87+
labels: ['verification-needed']
88+
});

0 commit comments

Comments
 (0)