Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:add check for username that opens isssue #142

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
tim-schilling marked this conversation as resolved.
Show resolved Hide resolved
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 }}
Loading