Skip to content

Commit

Permalink
fix:add check for username that opens isssue
Browse files Browse the repository at this point in the history
  • Loading branch information
cunla authored and tim-schilling committed Jan 7, 2025
1 parent d4bc10e commit bb9f41d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/add_member.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,26 @@ jobs:
run:
python -c "print('USERNAME='+'${{ github.event.issue.title }}'.split(' - ')[1])" >> $GITHUB_ENV

- name: Check whether username exists
- name: Validate add user request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Check whether the user exists
set +e
gh api /users/${{ env.USERNAME }} > /dev/null
if [ $? -ne 0 ]; then
gh issue comment ${{ env.ISSUE_NUMBER }} --body "User ${{ env.USERNAME }} does not exist."
exit 1
fi
- name: Check that user is not already in org
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set +e
# Check if the username is in the title is the same as the user who opened the issue
python -c "print('ISSUE_USER='+'${{ github.event.issue.user.login }}')" >> $GITHUB_ENV
if [ "${{ env.USERNAME }}" != "${{ env.ISSUE_USER }}" ]; then
gh issue comment ${{ env.ISSUE_NUMBER }} --body "If you want to add a different user, please create a PR for it"
exit 1
fi
# Check if the user is already a member of the org
gh api /orgs/django-commons/members/${{ env.USERNAME }} > /dev/null
if [ $? -eq 0 ]; then
gh issue comment ${{ env.ISSUE_NUMBER }} --body "User ${{ env.USERNAME }} is already a member of django-commons."
Expand Down Expand Up @@ -82,5 +86,6 @@ jobs:
--body "Fix #${{ env.ISSUE_NUMBER }}" \
--base main \
--head ${{ env.BRANCH_NAME }}
--label "New member"
env:
GITHUB_TOKEN: ${{ secrets.TERRAFORM_MANAGEMENT_GITHUB_TOKEN }}

0 comments on commit bb9f41d

Please sign in to comment.