Update add-label.js #1
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: Pull Request Verification | |
on: | |
pull_request_target: | |
types: [opened] | |
branches: | |
- '*' | |
# edited to all branches TWG | |
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('Successfully verified!') | |
} catch (verificationError) { | |
if (verificationError.status==404) { | |
await github.request('PATCH /repos/{owner}/{repo}/pulls/{pull_number}', { | |
owner : 'hackforla', | |
repo : 'website', | |
pull_number : prNumber, | |
state : 'closed' | |
}); | |
await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', { | |
owner : 'hackforla', | |
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.' | |
}); | |
} | |
} |