Skip to content

Update set-pr-labels.js #81

Update set-pr-labels.js

Update set-pr-labels.js #81

Workflow file for this run

name: Pull Request Verification
on:
pull_request_target:
types: [opened]
branches:
- '*'
jobs:
Check-Team-Membership:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.HACKFORLA_ADMIN_TOKEN }}
script: |
const prAuthor = context.payload.sender.login;
const prNumber = context.payload.number;
try {
const getMembershipStatus = await github.rest.teams.getMembershipForUserInOrg({
org: 'hackforla',
team_slug: 'website-write',
username: prAuthor
});
console.log(`PR author '${prAuthor}' successfully verified!`)
} catch (verificationError) {
if (verificationError.status==404) {
console.log(`PR author '${prAuthor}' not a team member- closing PR.`)
await github.request('PATCH /repos/{owner}/{repo}/pulls/{pull_number}', {
owner : 't-will-gillis',
repo : 'website',
pull_number : prNumber,
state : 'closed'
});
await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', {
owner : 't-will-gillis',
repo : 'website',
issue_number : prNumber,
body : 'You must be a member of the HFLA website team in order to create pull requests. Please see our page on how to join us as a member at HFLA: https://www.hackforla.org/getting-started. If you have been though onboarding, and feel this message in error, please message us in the #hfla-site team slack channel with the link to this PR.'
});
}
}