Commit bb9f41d 1 parent d4bc10e commit bb9f41d Copy full SHA for bb9f41d
File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -35,22 +35,26 @@ jobs:
35
35
run :
36
36
python -c "print('USERNAME='+'${{ github.event.issue.title }}'.split(' - ')[1])" >> $GITHUB_ENV
37
37
38
- - name : Check whether username exists
38
+ - name : Validate add user request
39
39
env :
40
40
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41
41
run : |
42
+ # Check whether the user exists
42
43
set +e
43
44
gh api /users/${{ env.USERNAME }} > /dev/null
44
45
if [ $? -ne 0 ]; then
45
46
gh issue comment ${{ env.ISSUE_NUMBER }} --body "User ${{ env.USERNAME }} does not exist."
46
47
exit 1
47
48
fi
48
49
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
54
58
gh api /orgs/django-commons/members/${{ env.USERNAME }} > /dev/null
55
59
if [ $? -eq 0 ]; then
56
60
gh issue comment ${{ env.ISSUE_NUMBER }} --body "User ${{ env.USERNAME }} is already a member of django-commons."
82
86
--body "Fix #${{ env.ISSUE_NUMBER }}" \
83
87
--base main \
84
88
--head ${{ env.BRANCH_NAME }}
89
+ --label "New member"
85
90
env :
86
91
GITHUB_TOKEN : ${{ secrets.TERRAFORM_MANAGEMENT_GITHUB_TOKEN }}
You can’t perform that action at this time.
0 commit comments