forked from hackforla/website
-
Notifications
You must be signed in to change notification settings - Fork 2
40 lines (40 loc) · 1.69 KB
/
pr-verification.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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.'
});
}
}