-
Notifications
You must be signed in to change notification settings - Fork 4
46 lines (42 loc) · 1.61 KB
/
new_member.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
41
42
43
44
45
46
name: Conditional Invite to Organization on Approval Comment
on:
issue_comment:
types: [created]
jobs:
check-team-membership:
runs-on: ubuntu-latest
outputs:
is_team_member: ${{ steps.check_membership.outputs.is_team_member }}
steps:
- name: Check if commenter is in the admins team
id: check_membership
run: |
ROLE=$(gh api -X GET /orgs/{org}/teams/{team_slug}/memberships/${{ github.event.comment.user.login }} --jq '.role')
if [[ "$ROLE" == "maintainer" ]]; then
echo "is_team_member=true" >> $GITHUB_OUTPUT
else
echo "is_team_member=false" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.ORG_CONTROLS_PAT }}
continue-on-error: true # Prevents the workflow from failing if the user is not a team member.
invite:
needs: check-team-membership
if: needs.check-team-membership.outputs.is_team_member == 'true' && github.event.comment.body == 'Approved'
runs-on: ubuntu-latest
steps:
- name: Fetch user to invite from issue title
run: echo "User to invite is ${{ github.event.issue.author.login }}"
- name: Invite User to Organization
uses: octokit/[email protected]
with:
route: PUT /orgs/{org}/memberships/{username}
org: 'django-community'
username: ${{ github.event.issue.author.login }}
role: member
env:
GITHUB_TOKEN: ${{ secrets.ORG_CONTROLS_PAT }}
- name: Close Issue
if: success()
run: |
gh issue close ${{ github.event.issue.number }}