diff --git a/.github/workflows/contributor-guidance.yml b/.github/workflows/contributor-guidance.yml index 4035ea932077..d43e5128cc4f 100644 --- a/.github/workflows/contributor-guidance.yml +++ b/.github/workflows/contributor-guidance.yml @@ -70,6 +70,25 @@ jobs: contents: read pull-requests: write steps: + - name: Find other open pull requests + id: other-prs + if: needs.contributor.outputs.is_first_time == 'true' + # Still post the welcome if this advisory lookup fails. + continue-on-error: true + shell: bash + env: + GH_TOKEN: ${{ github.token }} + AUTHOR_ID: ${{ github.event.pull_request.user.id }} + NUMBER: ${{ github.event.pull_request.number }} + run: | + # List PRs directly to avoid search-index delays after creation. + pull_requests=$(gh api --paginate --slurp \ + "/repos/$GITHUB_REPOSITORY/pulls?state=open&per_page=100" | + jq -r --argjson author "$AUTHOR_ID" --argjson number "$NUMBER" \ + '[.[][] | select(.user.id == $author and .number != $number)] | + sort_by(.number) | map("#\(.number)") | join(", ")') + echo "pull_requests=$pull_requests" >> "$GITHUB_OUTPUT" + - name: Scan contributor activity id: agentscan # The welcome should still be posted if this advisory scan fails. @@ -98,6 +117,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} IS_FIRST_TIME: ${{ needs.contributor.outputs.is_first_time }} NUMBER: ${{ github.event.pull_request.number }} + OTHER_OPEN_PRS: ${{ steps.other-prs.outputs.pull_requests }} WELCOME_MESSAGE: >2- Welcome to Node.js, and thank you for your first contribution! @@ -114,6 +134,10 @@ jobs: For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. + MULTIPLE_PRS_MESSAGE: |- + > [!IMPORTANT] + > Please wait until your first pull request has landed in `main` before opening another. + > See the [pull request guidelines](https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md#pull-requests). CAUTION_MESSAGE: >- > [!CAUTION] @@ -129,6 +153,10 @@ jobs: [automation policy](https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md#automation-and-bots) for additional context. run: | + if [[ "$IS_FIRST_TIME" == "true" && -n "$OTHER_OPEN_PRS" ]]; then + WELCOME_MESSAGE+=$'\n\n'"$MULTIPLE_PRS_MESSAGE"$'\n>\n'"> Other open PRs: $OTHER_OPEN_PRS" + fi + if [[ "$IS_FIRST_TIME" == "true" && "$ADD_CAUTION" == "true" ]]; then body="$WELCOME_MESSAGE"$'\n\n'"$CAUTION_MESSAGE" elif [[ "$IS_FIRST_TIME" == "true" ]]; then