[CI] Fix auto-label workflow - codeowners & listFiles (#9890)

This commit is contained in:
Jesse Hills 2025-07-25 21:40:42 +12:00 committed by GitHub
parent 773a8b8fb7
commit 457689fa1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,11 +89,15 @@ jobs:
// Check for mega-PR early - if present, skip most automatic labeling // Check for mega-PR early - if present, skip most automatic labeling
const isMegaPR = currentLabels.includes('mega-pr'); const isMegaPR = currentLabels.includes('mega-pr');
const { data: prFiles } = await github.rest.pulls.listFiles({ // Get all PR files with automatic pagination
owner, const prFiles = await github.paginate(
repo, github.rest.pulls.listFiles,
pull_number: pr_number {
}); owner,
repo,
pull_number: pr_number
}
);
// Calculate data from PR files // Calculate data from PR files
const changedFiles = prFiles.map(file => file.filename); const changedFiles = prFiles.map(file => file.filename);
@ -298,9 +302,10 @@ jobs:
const dir = pattern.slice(0, -1); const dir = pattern.slice(0, -1);
regex = new RegExp(`^${dir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`); regex = new RegExp(`^${dir.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`);
} else if (pattern.includes('*')) { } else if (pattern.includes('*')) {
// First escape all regex special chars except *, then replace * with .*
const regexPattern = pattern const regexPattern = pattern
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') .replace(/[.+?^${}()|[\]\\]/g, '\\$&')
.replace(/\\*/g, '.*'); .replace(/\*/g, '.*');
regex = new RegExp(`^${regexPattern}$`); regex = new RegExp(`^${regexPattern}$`);
} else { } else {
regex = new RegExp(`^${pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`); regex = new RegExp(`^${pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`);