[READ-ONLY] a fast, modern browser for the npm registry
at main 52 lines 2.0 kB view raw
1name: welcome 2 3on: 4 pull_request_target: 5 types: 6 - closed 7 8permissions: {} 9 10jobs: 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}`);