Skip to content

Conversation

@LiviaMedeiros
Copy link
Member

Having to fill pr-url in docs is sometimes annoying, since there's no guaranteed way to predict the PR number before pushing the changes.
This PR adds tool that searches for https://github.com/nodejs/node/pull/FILLME and posts https://github.com/nodejs/node/pull/12345 (where 12345 is actual PR number) as code review suggestion (```suggestion).
To avoid unnecessary flooding, it triggers only on initial open, and only if pr-url was explicitly set as https://github.com/nodejs/node/pull/FILLME in the files.

This also could be addressed as local tool, or even as ncu feature (e.g. git node i-feel-lucky to guess the next number, fill and commit).

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/actions

@nodejs-github-bot nodejs-github-bot added meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory. labels Jan 1, 2026
Comment on lines 28 to 29
REPO: ${{ github.repository }}
SHA: ${{ github.sha }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use $GITHUB_REPOSITORY and $GITHUB_SHA that are already defined (see https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables)


// https://docs.github.com/en/rest/pulls/reviews?apiVersion=2022-11-28#create-a-review-for-a-pull-request
await fetch(
new URL(`repos/${REPO}/pulls/${PR_NUMBER}/reviews`, 'https://api.github.com'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new URL(`repos/${REPO}/pulls/${PR_NUMBER}/reviews`, 'https://api.github.com'),
new URL(`repos/${REPO}/pulls/${PR_NUMBER}/reviews`, process.env.GITHUB_API_URL || 'https://api.github.com'),

Comment on lines 27 to 30
const res = await fetch(
new URL(`repos/${REPO}/pulls/${PR_NUMBER}/files`, 'https://api.github.com'),
{ headers },
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to use octokit here, rather than manually interacting with the API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either way, by default manual requests should have slightly less overhead. Are there benefits from using octikit here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there benefits from using octikit here?

Primarily that if the API structure changes, Octokit will adjust accordingly without the need for us to make any manual changes

LiviaMedeiros and others added 2 commits January 2, 2026 17:57
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull_request trigger can't access secrets from fork PRs.

node-version: latest
- run: ./tools/actions/suggest-fill-prurl.mjs
env:
GH_TOKEN: ${{ secrets.GH_USER_TOKEN }}
Copy link
Contributor

@aduh95 aduh95 Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GH_TOKEN: ${{ secrets.GH_USER_TOKEN }}
GH_TOKEN: ${{ github.token }}

Copy link
Member

@avivkeller avivkeller Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even so, fork PR tokens don't have the necessary access. I'd recommend changing the trigger to pull_request_target (with all security precautions needed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants