Skip to content

Commit 135dd7c

Browse files
authored
Merge pull request #128 from Asymtode712/CommunityFeat-patch-2
Update invitation.yml
2 parents b001180 + 1c195f2 commit 135dd7c

File tree

2 files changed

+78
-11
lines changed

2 files changed

+78
-11
lines changed

.github/workflows/autocomment-pr-merge.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,33 @@ on:
44
pull_request:
55
types: [closed]
66

7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
711
jobs:
8-
notify:
9-
if: github.event.pull_request.merged == true
12+
comment:
1013
runs-on: ubuntu-latest
14+
permissions:
15+
pull-requests: write
16+
if: github.event.pull_request.merged == true
1117

1218
steps:
13-
- name: Post merge comment
19+
- name: Checkout Repository
20+
uses: actions/checkout@v2
21+
22+
- name: Add Comment to Issue
1423
env:
1524
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1625
run: |
17-
curl -H "Authorization: token $GITHUB_TOKEN" \
18-
-X POST \
19-
-d '{"body":"🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀"}' \
20-
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"
26+
COMMENT=$(cat <<EOF
27+
{
28+
"body": "🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀"
29+
}
30+
EOF
31+
)
32+
curl -X POST \
33+
-H "Authorization: Bearer $GITHUB_TOKEN" \
34+
-H "Accept: application/vnd.github.v3+json" \
35+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
36+
-d "$COMMENT"

.github/workflows/invitation.yml

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,68 @@
1+
name: Automate Invitation
2+
13
on:
24
issues:
35
types: [labeled]
46

57
jobs:
6-
automate_invite:
8+
handle_label:
79
runs-on: ubuntu-latest
10+
811
steps:
9-
- name: Invite on label
12+
- name: Check if Label is 'invite me to the community'
13+
id: check_label
14+
run: |
15+
if [[ "${{ github.event.label.name }}" != "invite me to the community" ]]; then
16+
echo "Label is not 'invite me to the community'. Exiting."
17+
exit 0
18+
fi
19+
20+
- name: Create Issue in Support Repository
21+
id: create_issue
22+
if: ${{ steps.check_label.outcome == 'success' }}
23+
uses: actions/github-script@v5
24+
with:
25+
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
26+
script: |
27+
const issue = context.payload.issue;
28+
const { owner, repo } = context.repo;
29+
const response = await github.rest.issues.create({
30+
owner: 'Recode-Hive',
31+
repo: 'Support',
32+
title: issue.title,
33+
body: issue.body,
34+
labels: ['invite me to the community'],
35+
});
36+
core.setOutput('issue_number', response.data.number);
37+
38+
- name: Close Original Issue in StackOverflow Repository
39+
if: ${{ steps.check_label.outcome == 'success' }}
40+
uses: actions/github-script@v5
41+
with:
42+
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
43+
script: |
44+
const issue = context.payload.issue;
45+
await github.rest.issues.update({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
issue_number: issue.number,
49+
state: 'closed'
50+
});
51+
52+
- name: Invite on Label
53+
if: ${{ steps.check_label.outcome == 'success' }}
1054
uses: vj-abigo/[email protected]
1155
with:
1256
organization: Recode-Hive
1357
label: invite me to the community
14-
repo-token: ${{ secrets.GITHUB_TOKEN }}
15-
comment: "<b>Invitation sent to join the GitHub Organisation. Welcome to the community 🎉</b><br><br>Don't forget after accepting to make it public so it appears on your GitHub profile for everyone else to see. You can do this by finding your name in the GitHub organisation list and change the dropdown to public https://github.com/orgs/Recode-Hive/people<br><br>"
58+
repo-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
59+
comment: |
60+
<b>Invitation sent to join the GitHub Organisation. Welcome to the community 🎉</b><br><br>
61+
Don't forget after accepting to make it public so it appears on your GitHub profile for everyone else to see. You can do this by finding your name in the GitHub organisation list and change the dropdown to public https://github.com/orgs/Recode-Hive/people<br><br>
62+
Tips for practising:<br><br>
63+
Customise your GitHub profile, here is a course on that: https://www.udemy.com/course/make-your-github-profile-stand-out/<br>
64+
Practice repo, instructions on how to add your name to the README https://github.com/Recode-Hive/hacktoberfest-practice<br>
65+
Remember contributing to open source is not just about code, it's about collaboration, communication and adding value<br>
66+
I hope that helps
1667
env:
1768
INVITE_TOKEN: ${{ secrets.INVITE_TOKEN }}

0 commit comments

Comments
 (0)