Skip to content

Commit ace4993

Browse files
author
Vasudev Jaiswal
authored
Merge pull request #393 from Jaidevstudio/VasudevJaiswal-patch-4
Update invitation.yml
2 parents 2d5d6d3 + 701b8e9 commit ace4993

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

.github/workflows/invitation.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Invite User to Organization
2+
13
on:
24
issues:
35
types: [labeled]
@@ -16,26 +18,35 @@ jobs:
1618
- name: Send Organization Invitation
1719
run: |
1820
echo "Inviting user: $ISSUE_USER"
19-
curl -X PUT -H "Authorization: token ${{ secrets.INVITE_TOKEN }}" \
20-
-H "Accept: application/vnd.github.v3+json" \
21-
"https://api.github.com/orgs/JDStudio/memberships/$ISSUE_USER" \
22-
-d '{"role":"member"}'
21+
RESPONSE=$(curl -s -o response.json -w "%{http_code}" -X PUT \
22+
-H "Authorization: token ${{ secrets.INVITE_TOKEN }}" \
23+
-H "Accept: application/vnd.github.v3+json" \
24+
"https://api.github.com/orgs/Jaidevstudio/memberships/$ISSUE_USER" \
25+
-d '{"role":"member"}')
26+
27+
echo "GitHub API Response: $(cat response.json)"
28+
if [[ "$RESPONSE" -ne 200 && "$RESPONSE" -ne 201 ]]; then
29+
echo "Failed to send invitation"
30+
exit 1
31+
fi
2332
2433
- name: Verify invitation status
2534
run: |
2635
echo "Checking if the user has been invited..."
2736
RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.INVITE_TOKEN }}" \
28-
"https://api.github.com/orgs/JDStudio/invitations")
37+
"https://api.github.com/orgs/Jaidevstudio/invitations")
2938
echo "GitHub API Response: $RESPONSE"
3039
3140
- name: Post message and close the issue
3241
run: |
33-
ISSUE_NUMBER=$(echo "${{ github.event.issue.number }}")
34-
42+
ISSUE_NUMBER=${{ github.event.issue.number }}
43+
3544
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
36-
-d "{\"body\": \"The invitation has been sent to @$ISSUE_USER to join the GitHub Organization. If you don't see it, please check your email or visit https://github.com/orgs/JDStudio/invitations.\"}" \
45+
-H "Accept: application/vnd.github.v3+json" \
46+
-d "{\"body\": \"The invitation has been sent to @$ISSUE_USER to join the GitHub Organization. If you don't see it, please check your email or visit https://github.com/orgs/Jaidevstudio/invitations.\"}" \
3747
"https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER/comments"
3848
3949
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
50+
-H "Accept: application/vnd.github.v3+json" \
4051
-d '{"state": "closed"}' \
4152
"https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER"

0 commit comments

Comments
 (0)