|
1 | | -name: welcome |
| 1 | +name: Welcome |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | pull_request_target: |
5 | | - types: |
6 | | - - closed |
| 5 | + branches: [main] |
| 6 | + types: [opened] |
7 | 7 |
|
8 | | -permissions: {} |
| 8 | +permissions: |
| 9 | + pull-requests: write |
9 | 10 |
|
10 | 11 | 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 | + |
17 | 17 | steps: |
18 | | - - name: 🎉 Welcome new contributor |
19 | | - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 18 | + - uses: actions/first-interaction@1c4688942c71f71d4f5502a26ea67c331730fa4d # v3.1.0 |
20 | 19 | 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 }}! 🚀 |
44 | 22 |
|
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)! |
51 | 24 |
|
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