Skip to content

Commit b74bd81

Browse files
committed
feat: introduce second workflow for welcoming message and adapt merged contribution workflow
1 parent bdac7f4 commit b74bd81

File tree

3 files changed

+84
-25
lines changed

3 files changed

+84
-25
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Claim Contributor Message
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
8+
permissions: {}
9+
10+
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
17+
steps:
18+
- name: 🎉 Welcome new contributor
19+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
20+
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');
44+
45+
await github.rest.issues.createComment({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
issue_number: pr.number,
49+
body,
50+
});
51+
52+
console.log(`Welcomed new contributor @${author} on PR #${pr.number}`);

.github/workflows/welcome-open.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Welcome Message
2+
3+
on:
4+
pull_request_target:
5+
branches: [main]
6+
types: [opened]
7+
8+
permissions:
9+
pull-requests: write
10+
11+
jobs:
12+
greeting:
13+
name: Greet First-Time Contributors
14+
if: github.repository == 'npmx-dev/npmx.dev'
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/first-interaction@1c4688942c71f71d4f5502a26ea67c331730fa4d # v3.1.0
19+
with:
20+
pr_message: |
21+
Hello! Thank you for opening your **first PR** to npmx, @${{ github.event.pull_request.user.login }}! 🚀
22+
23+
Here’s what will happen next:
24+
25+
1. Our GitHub bots will run to check your changes.
26+
If they spot any issues you will see some error messages on this PR.
27+
Don’t hesitate to ask any questions if you’re not sure what these mean!
28+
29+
2. In a few minutes, you’ll be able to see a preview of your changes on Vercel 🤩
30+
31+
3. One or more of our maintainers will take a look and may ask you to make changes.
32+
We try to be responsive, but don’t worry if this takes a few days.

.github/workflows/welcome.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)