tools: add GitHub Action to ping code owners#63310
Open
mahmutovicr wants to merge 1 commit into
Open
Conversation
Collaborator
|
Review requested:
|
avivkeller
requested changes
Jun 30, 2026
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| REPO_OWNER: ${{ github.repository_owner }} | ||
| REPO_NAME: ${{ github.event.repository.name }} | ||
| run: node tools/actions/ping-owners.mjs No newline at end of file |
Member
There was a problem hiding this comment.
Still needs a newline
Suggested change
| run: node tools/actions/ping-owners.mjs | |
| run: node tools/actions/ping-owners.mjs | |
Migrates the ping code owners functionality from the GitHub bot to a GitHub Action, as part of removing the bot infrastructure. Refs: nodejs#51236 Signed-off-by: Rahman Mahmutovic <mahmutovicrahman5@gmail.com>
41b1da0 to
9db79ba
Compare
avivkeller
reviewed
Jul 1, 2026
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| REPO_OWNER: ${{ github.repository_owner }} | ||
| REPO_NAME: ${{ github.event.repository.name }} | ||
| run: node tools/actions/ping-owners.mjs No newline at end of file |
Member
There was a problem hiding this comment.
Still needs a newline
Suggested change
| run: node tools/actions/ping-owners.mjs | |
| run: node tools/actions/ping-owners.mjs | |
Comment on lines
55
to
71
Member
There was a problem hiding this comment.
Suggested change
| const changedFiles = await getChangedFiles(); | |
| const codeownersContent = readFileSync('.github/CODEOWNERS', 'utf8'); | |
| const owners = getOwnersForPaths(codeownersContent, changedFiles); | |
| if (owners.length !== 0) { | |
| await githubRequest( | |
| `/repos/${REPO_OWNER}/${REPO_NAME}/issues/${PR_NUMBER}/comments`, | |
| { | |
| method: 'POST', | |
| body: JSON.stringify({ body: getCommentBody(owners) }), | |
| }, | |
| ); | |
| } |
Member
There was a problem hiding this comment.
Suggested change
| async function githubRequest(path, options = {}, retries = 3) { | |
| for (let attempt = 1; attempt <= retries; attempt++) { | |
| const response = await fetch(`https://api.github.com${path}`, { | |
| ...options, | |
| headers: { | |
| 'Authorization': `Bearer ${GITHUB_TOKEN}`, | |
| 'Accept': 'application/vnd.github.v3+json', | |
| 'X-GitHub-Api-Version': '2022-11-28', | |
| ...options.headers, | |
| }, | |
| }); | |
| if (response.ok) { | |
| return response.json(); | |
| } | |
| const retryable = response.status === 429 || response.status >= 500; | |
| if (!retryable || attempt === retries) { | |
| throw new Error(`GitHub API error: ${response.status} ${response.statusText}`); | |
| } | |
| await setTimeout(1000 * attempt); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates the ping code owners functionality from the GitHub bot to a GitHub Action, as part of removing the bot infrastructure.
Refs: #51236