Skip to content

Commit bdac7f4

Browse files
committed
feat: welcome first contributors when PR opens
1 parent 1824c62 commit bdac7f4

File tree

1 file changed

+15
-42
lines changed

1 file changed

+15
-42
lines changed

.github/workflows/welcome.yml

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,25 @@
1-
name: welcome
1+
name: Welcome
22

33
on:
44
pull_request_target:
5-
types:
6-
- closed
5+
branches: [main]
6+
types: [opened]
77

8-
permissions: {}
8+
permissions:
9+
pull-requests: write
910

1011
jobs:
11-
welcome:
12-
permissions:
13-
pull-requests: write # to comment on PRs
14-
if: github.repository == 'npmx-dev/npmx.dev' && github.event.pull_request.merged == true
15-
runs-on: ubuntu-slim
16-
name: 🎉 Welcome new contributor
12+
greeting:
13+
name: Greet First-Time Contributors
14+
if: github.repository == 'npmx-dev/npmx.dev'
15+
runs-on: ubuntu-latest
16+
1717
steps:
18-
- name: 🎉 Welcome new contributor
19-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
18+
- uses: actions/first-interaction@1c4688942c71f71d4f5502a26ea67c331730fa4d # v3.1.0
2019
with:
21-
script: |
22-
const pr = context.payload.pull_request;
23-
const author = pr.user.login;
24-
25-
// Check if this is the author's first merged PR
26-
const { data: prs } = await github.rest.search.issuesAndPullRequests({
27-
q: `repo:${context.repo.owner}/${context.repo.repo} type:pr is:merged author:${author}`,
28-
});
29-
30-
// If the only merged PR is this one, it's their first contribution
31-
if (prs.total_count !== 1) {
32-
console.log(`@${author} already has ${prs.total_count} merged PRs — skipping welcome comment.`);
33-
return;
34-
}
35-
36-
const emojis = ['🎉', '🥳', '🎊', '🚀', '⭐', '💫', '✨', '💪', '👏', '🙌', '🤩', '💥'];
37-
const emoji = emojis[Math.floor(Math.random() * emojis.length)];
38-
39-
const body = [
40-
`Thanks for your first contribution, @${author}! ${emoji}`,
41-
'',
42-
`We'd love to welcome you to the npmx community. Come and say hi on [Discord](https://chat.npmx.dev)! And once you've joined, visit [npmx.wamellow.com](https://npmx.wamellow.com/) to claim the **contributor** role.`,
43-
].join('\n');
20+
pr_message: |
21+
Thanks for your first contribution, @${{ github.event.pull_request.user.login }}! 🚀
4422
45-
await github.rest.issues.createComment({
46-
owner: context.repo.owner,
47-
repo: context.repo.repo,
48-
issue_number: pr.number,
49-
body,
50-
});
23+
We'd love to welcome you to the npmx community. While you wait for a review, come and say hi on [Discord](https://chat.npmx.dev)!
5124
52-
console.log(`Welcomed new contributor @${author} on PR #${pr.number}`);
25+
Once your pull request is merged, you'll be able to visit [npmx.wamellow.com](https://npmx.wamellow.com/) to claim your **contributor** role. 🚀

0 commit comments

Comments
 (0)