Skip to content

Commit bb9f41d

Browse files
cunlatim-schilling
authored andcommitted
fix:add check for username that opens isssue
1 parent d4bc10e commit bb9f41d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

.github/workflows/add_member.yml

+11-6
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,26 @@ jobs:
3535
run:
3636
python -c "print('USERNAME='+'${{ github.event.issue.title }}'.split(' - ')[1])" >> $GITHUB_ENV
3737

38-
- name: Check whether username exists
38+
- name: Validate add user request
3939
env:
4040
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4141
run: |
42+
# Check whether the user exists
4243
set +e
4344
gh api /users/${{ env.USERNAME }} > /dev/null
4445
if [ $? -ne 0 ]; then
4546
gh issue comment ${{ env.ISSUE_NUMBER }} --body "User ${{ env.USERNAME }} does not exist."
4647
exit 1
4748
fi
4849
49-
- name: Check that user is not already in org
50-
env:
51-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
run: |
53-
set +e
50+
# Check if the username is in the title is the same as the user who opened the issue
51+
python -c "print('ISSUE_USER='+'${{ github.event.issue.user.login }}')" >> $GITHUB_ENV
52+
if [ "${{ env.USERNAME }}" != "${{ env.ISSUE_USER }}" ]; then
53+
gh issue comment ${{ env.ISSUE_NUMBER }} --body "If you want to add a different user, please create a PR for it"
54+
exit 1
55+
fi
56+
57+
# Check if the user is already a member of the org
5458
gh api /orgs/django-commons/members/${{ env.USERNAME }} > /dev/null
5559
if [ $? -eq 0 ]; then
5660
gh issue comment ${{ env.ISSUE_NUMBER }} --body "User ${{ env.USERNAME }} is already a member of django-commons."
@@ -82,5 +86,6 @@ jobs:
8286
--body "Fix #${{ env.ISSUE_NUMBER }}" \
8387
--base main \
8488
--head ${{ env.BRANCH_NAME }}
89+
--label "New member"
8590
env:
8691
GITHUB_TOKEN: ${{ secrets.TERRAFORM_MANAGEMENT_GITHUB_TOKEN }}

0 commit comments

Comments
 (0)