Skip to content

Commit b360d7b

Browse files
authored
github action for first time contributors when PR merged (#1186)
* github action for merged PR to ask user for their username if they're a member * improve logic for workflow to only check first time contributors * add server invite via github secrets * use variables instead of secret for invite link * fix develop branch pattern
1 parent 77f1b69 commit b360d7b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/discord-member.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Comment When PR Merged
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
branches:
7+
- develop
8+
9+
10+
jobs:
11+
if_merged:
12+
if: github.event.pull_request.merged == true
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/github-script@v7
16+
with:
17+
github-token: ${{secrets.GITHUB_TOKEN}}
18+
script: |
19+
const creator = context.payload.sender.login
20+
const opts = github.rest.issues.listForRepo.endpoint.merge({
21+
...context.issue,
22+
creator,
23+
state: 'all'
24+
})
25+
const issues = await github.paginate(opts)
26+
27+
for (const issue of issues) {
28+
if (issue.number === context.issue.number) {
29+
continue
30+
}
31+
32+
if (issue.pull_request) {
33+
return
34+
}
35+
}
36+
await github.rest.issues.createComment({
37+
issue_number: context.issue.number,
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
body: `Congratulations on your first contribution! We're excited to have you on board. Your work will be included in the next release, so stay tuned!
41+
Are you a Together-Java member on Discord? If so, please share your username here. If not, that’s perfectly fine! If you change your mind, here's the link: ${{vars.SERVER_INVITE}}.
42+
Why do we need your username? We’d like to give you a shoutout to show our gratitude!`
43+
})

0 commit comments

Comments
 (0)