File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 13
13
- name : Checkout Repository
14
14
uses : actions/checkout@v3
15
15
16
- - name : Install GitHub CLI
17
- run : |
18
- sudo apt-get install -y jq
19
- curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
20
- echo "deb [signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
21
- sudo apt update && sudo apt install gh -y
22
-
23
16
- name : Authenticate with GitHub CLI
24
17
run : |
25
18
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
33
26
COMMENT_BODY=$(jq -r '.comment.body' "$GITHUB_EVENT_PATH")
34
27
ISSUE_NUMBER=$(jq -r '.issue.number // .pull_request.number' "$GITHUB_EVENT_PATH")
35
28
29
+ ORG_NAME="devtron-labs"
30
+
31
+ # checks if the person is authorized to add labels or not
32
+ ORG_MEMBERSHIP_STATUS=$(gh api "orgs/$ORG_NAME/members/$COMMENT_AUTHOR" --silent --exit-status)
33
+
34
+ if [[ $? -ne 0 ]]; then
35
+ gh issue comment "$ISSUE_NUMBER" --body "Hi @$COMMENT_AUTHOR, you must be a member of the organization '$ORG_NAME' to add or remove labels."
36
+
37
+ echo "User '$COMMENT_AUTHOR' is not a member of the organization '$ORG_NAME'. Exiting."
38
+ exit 1
39
+ fi
40
+
41
+ echo "User '$COMMENT_AUTHOR' is a verified member of the organization '$ORG_NAME'. Adding label"
42
+
43
+
36
44
# Get the existing labels on the issue
37
45
EXISTING_LABELS=$(gh issue view "$ISSUE_NUMBER" --json labels -q '.labels[].name')
38
46
You can’t perform that action at this time.
0 commit comments