From 39016647dace4872519df9106a410acb63ce5362 Mon Sep 17 00:00:00 2001 From: Osama Mabkhot <99215291+O2sa@users.noreply.github.com> Date: Mon, 20 Apr 2026 02:42:54 +0300 Subject: [PATCH] chore: Add workflow to welcome first merged PR contributor --- .github/workflows/first-pr-merged.yml | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/first-pr-merged.yml diff --git a/.github/workflows/first-pr-merged.yml b/.github/workflows/first-pr-merged.yml new file mode 100644 index 0000000..ebb98ec --- /dev/null +++ b/.github/workflows/first-pr-merged.yml @@ -0,0 +1,47 @@ +name: First PR Merged Welcome + +on: + pull_request_target: + types: [closed] + +jobs: + welcome-on-merge: + # Only run if the PR was actually merged, not just closed + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Thank contributor and ask for star + uses: actions/github-script@v7 + with: + script: | + const { owner, repo } = context.repo; + const creator = context.payload.pull_request.user.login; + + // Fetch all merged PRs by this user + const response = await github.rest.pulls.list({ + owner, + repo, + state: 'closed', + creator: creator + }); + + // Filter to ensure we only count merged PRs + const mergedPrs = response.data.filter(pr => pr.merged_at !== null); + + // If this is their first successfully merged PR + if (mergedPrs.length === 1) { + const message = ` + Congratulations @${creator}! 🎊 Your first contribution has been merged! πŸš€ + + Thank you for helping improve the project. If you find this tool useful, please consider giving us a ⭐ **star on GitHub**β€”it helps more developers find our work! + `; + + await github.rest.issues.createComment({ + owner, + repo, + issue_number: context.payload.pull_request.number, + body: message + }); + }