Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 15 additions & 42 deletions .github/workflows/welcome.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,25 @@
name: welcome
name: Welcome

on:
pull_request_target:
types:
- closed
branches: [main]
types: [opened]

permissions: {}
permissions:
pull-requests: write

jobs:
welcome:
permissions:
pull-requests: write # to comment on PRs
if: github.repository == 'npmx-dev/npmx.dev' && github.event.pull_request.merged == true
runs-on: ubuntu-slim
name: 🎉 Welcome new contributor
greeting:
name: Greet First-Time Contributors
if: github.repository == 'npmx-dev/npmx.dev'
runs-on: ubuntu-latest

steps:
- name: 🎉 Welcome new contributor
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
- uses: actions/first-interaction@1c4688942c71f71d4f5502a26ea67c331730fa4d # v3.1.0
with:
script: |
const pr = context.payload.pull_request;
const author = pr.user.login;

// Check if this is the author's first merged PR
const { data: prs } = await github.rest.search.issuesAndPullRequests({
q: `repo:${context.repo.owner}/${context.repo.repo} type:pr is:merged author:${author}`,
});

// If the only merged PR is this one, it's their first contribution
if (prs.total_count !== 1) {
console.log(`@${author} already has ${prs.total_count} merged PRs — skipping welcome comment.`);
return;
}

const emojis = ['🎉', '🥳', '🎊', '🚀', '⭐', '💫', '✨', '💪', '👏', '🙌', '🤩', '💥'];
const emoji = emojis[Math.floor(Math.random() * emojis.length)];

const body = [
`Thanks for your first contribution, @${author}! ${emoji}`,
'',
`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.`,
].join('\n');
pr_message: |
Thanks for your first contribution, @${{ github.event.pull_request.user.login }}! 🚀

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body,
});
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)!

console.log(`Welcomed new contributor @${author} on PR #${pr.number}`);
Once your pull request is merged, you'll be able to visit [npmx.wamellow.com](https://npmx.wamellow.com/) to claim your **contributor** role. 🚀
Loading