-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
49 lines (43 loc) · 1.3 KB
/
action.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
47
48
49
name: Check member exists in GitHub Team
description: 'GitHub Actions to check if an username exists in Team'
branding:
icon: 'users'
color: 'red'
inputs:
org_slug:
description: Name of the organization
required: true
team_slug:
description: Name of Team to check
required: true
gh_token:
description: GitHub Token with right permission
required: true
username:
description: Type username to check
required: true
outputs:
exists-in-team:
description: If the member exists in the team
value: ${{ steps.exists-team.outputs.exists-in-team }}
runs:
using: composite
steps:
- id: exists-team
shell: bash
run: |
EXIST_TEAM=$(curl -s -w "%{http_code}\n" -o /dev/null \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/"$ORG"/teams/"$TEAM"/memberships/"$USERNAME")
if [[ "$EXIST_TEAM" -eq 200 ]]; then
echo "exists-in-team=true" >> $GITHUB_OUTPUT
else
echo "exists-in-team=false" >> $GITHUB_OUTPUT
fi
env:
ORG: ${{ inputs.org_slug }}
TEAM: ${{ inputs.team_slug }}
GH_TOKEN: ${{ inputs.gh_token }}
USERNAME: ${{ inputs.username }}