[Backport release-26.05] ci/github-script/bot: label PRs for unmaintained packages (#566212)

This commit is contained in:
Matt Sturgeon
2026-09-23 15:35:52 +00:00
committed by GitHub

View File

@@ -465,9 +465,10 @@ export default async ({ github, context, core, dry }) => {
let owners = []
try {
// TODO: Create owner map similar to maintainer map.
owners = (await readFile(`${pull_number}/owners.txt`, 'utf-8')).split(
'\n',
)
owners =
(await readFile(`${pull_number}/owners.txt`, 'utf-8')).match(
/[^\n]+/g,
) || []
} catch (e) {
// Older artifacts don't have the owners.txt, yet.
if (e.code !== 'ENOENT') throw e
@@ -483,6 +484,18 @@ export default async ({ github, context, core, dry }) => {
if (e.code !== 'ENOENT') throw e
}
// TODO: Use maintainer map instead of the artifact.
const user_maintainers = Object.keys(
JSON.parse(
await readFile(`${pull_number}/maintainers.json`, 'utf-8'),
),
).map((id) => parseInt(id))
prLabels['7.unmaintained'] =
user_maintainers.length === 0 &&
team_maintainers.length === 0 &&
owners.length === 0
// We set this label earlier already, but the current PR state can be very different
// after handleReviewers has requested reviews, so update it in this case to prevent
// this label from flip-flopping.
@@ -494,12 +507,7 @@ export default async ({ github, context, core, dry }) => {
dry,
pull_request,
reviews,
// TODO: Use maintainer map instead of the artifact.
user_maintainers: Object.keys(
JSON.parse(
await readFile(`${pull_number}/maintainers.json`, 'utf-8'),
),
).map((id) => parseInt(id)),
user_maintainers,
team_maintainers,
owners,
getUser,