Skip to content

tools: add GitHub Action to ping code owners#63310

Open
mahmutovicr wants to merge 1 commit into
nodejs:mainfrom
mahmutovicr:migrate-ping-owners-to-actions
Open

tools: add GitHub Action to ping code owners#63310
mahmutovicr wants to merge 1 commit into
nodejs:mainfrom
mahmutovicr:migrate-ping-owners-to-actions

Conversation

@mahmutovicr

Copy link
Copy Markdown

Migrates the ping code owners functionality from the GitHub bot to a GitHub Action, as part of removing the bot infrastructure.

Refs: #51236

@nodejs-github-bot

Copy link
Copy Markdown
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 May 14, 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Newline

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 9db79ba.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still needs a newline

Suggested change
run: node tools/actions/ping-owners.mjs
run: node tools/actions/ping-owners.mjs

Comment thread .github/workflows/ping-code-owners.yml Outdated
Comment thread tools/actions/ping-owners.mjs Outdated
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>
@mahmutovicr mahmutovicr force-pushed the migrate-ping-owners-to-actions branch from 41b1da0 to 9db79ba Compare July 1, 2026 12:27
@mahmutovicr mahmutovicr requested a review from avivkeller July 1, 2026 12:35
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still needs a newline

Suggested change
run: node tools/actions/ping-owners.mjs
run: node tools/actions/ping-owners.mjs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
}

Comment on lines 55 to 71

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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) }),
},
);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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);
}
}

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.

3 participants