From 1b2bc440a217c77c0adace9afd61c6537ba3c3d7 Mon Sep 17 00:00:00 2001 From: Osama Mabkhot <99215291+O2sa@users.noreply.github.com> Date: Mon, 20 Apr 2026 21:41:45 +0300 Subject: [PATCH] chore: Introduce delay before thanking first-time contributors Added a delay before fetching merged PRs to ensure API reflects the merge. --- .github/workflows/first-pr-merged.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/first-pr-merged.yml b/.github/workflows/first-pr-merged.yml index ebb98ec..52701da 100644 --- a/.github/workflows/first-pr-merged.yml +++ b/.github/workflows/first-pr-merged.yml @@ -16,9 +16,12 @@ jobs: uses: actions/github-script@v7 with: script: | + // Sleep for 3 seconds to ensure the API reflects the PR merge + await new Promise(resolve => setTimeout(resolve, 3000)); + 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, @@ -26,18 +29,18 @@ jobs: 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, @@ -45,3 +48,4 @@ jobs: body: message }); } + }