Add Endorsing Django Packages article by me! #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Member Verification Check | |
on: | |
pull_request: | |
types: [opened] | |
jobs: | |
verify-new-member: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Check PR title format | |
id: check-title | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const title = context.payload.pull_request.title; | |
if (!title.startsWith('[MEMBER]')) { | |
console.log('PR title does not start with [MEMBER], skipping verification check'); | |
return 'skip'; | |
} | |
return 'continue'; | |
- name: Check user account age | |
if: steps.check-title.outputs.result == 'continue' | |
id: check-user | |
uses: actions/github-script@v7 | |
env: | |
MIN_ACCOUNT_AGE_MONTHS: ${{ vars.MIN_ACCOUNT_AGE_MONTHS || '3' }} # Default to 3 months if not set | |
with: | |
script: | | |
const creator = context.payload.pull_request.user.login; | |
const response = await github.rest.users.getByUsername({ | |
username: creator | |
}); | |
const createdAt = new Date(response.data.created_at); | |
const now = new Date(); | |
const accountAgeInMonths = (now - createdAt) / (1000 * 60 * 60 * 24 * 30); | |
const minAgeMonths = parseInt(process.env.MIN_ACCOUNT_AGE_MONTHS); | |
console.log(`Account age in months: ${accountAgeInMonths}`); | |
console.log(`Required minimum age in months: ${minAgeMonths}`); | |
if (accountAgeInMonths < minAgeMonths) { | |
const message = [ | |
`👋 Hello @${creator}!`, | |
'', | |
`Thank you for your interest in joining our organization. We noticed that your GitHub account is less than ${minAgeMonths} months old.`, | |
'', | |
'To help us verify that you\'re a real person and maintain the security of our organization, please provide one of the following:', | |
'- A link to your LinkedIn profile', | |
'- Links to your other social media presence', | |
'- Any other form of verification that shows you\'re a real person', | |
'', | |
'Please provide this information in a comment on this PR.', | |
'', | |
'Note: This is an automated message to help prevent bot accounts from joining our organization.' | |
].join('\n'); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: message | |
}); | |
return 'new-account'; | |
} | |
return 'existing-account'; | |
- name: Add label if new account | |
if: steps.check-user.outputs.result == 'new-account' && steps.check-title.outputs.result == 'continue' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
labels: ['verification-needed'] | |
}); |