feat(workflow): exclude automated PRs and bot issues from locking

This commit is contained in:
CanbiZ (MickLesk)
2026-01-29 14:41:26 +01:00
parent 1c4c95723b
commit cc70f84d27
+15 -1
View File
@@ -22,15 +22,29 @@ jobs:
const lockDate = new Date(); const lockDate = new Date();
lockDate.setDate(lockDate.getDate() - daysBeforeLock); lockDate.setDate(lockDate.getDate() - daysBeforeLock);
// Exclude patterns (case-insensitive)
const excludePatterns = [
/automated pr/i,
/\[bot\]/i,
/dependabot/i
];
// Search for closed, unlocked issues older than 3 days // Search for closed, unlocked issues older than 3 days
const issues = await github.rest.search.issuesAndPullRequests({ const issues = await github.rest.search.issuesAndPullRequests({
q: `repo:${context.repo.owner}/${context.repo.repo} is:closed is:unlocked updated:<${lockDate.toISOString().split('T')[0]}`, q: `repo:${context.repo.owner}/${context.repo.repo} is:closed is:unlocked updated:<${lockDate.toISOString().split('T')[0]}`,
per_page: 50 per_page: 50
}); });
console.log(`Found ${issues.data.items.length} issues/PRs to lock`); console.log(`Found ${issues.data.items.length} issues/PRs to process`);
for (const item of issues.data.items) { for (const item of issues.data.items) {
// Skip excluded items
const shouldExclude = excludePatterns.some(pattern => pattern.test(item.title));
if (shouldExclude) {
console.log(`Skipped #${item.number}: "${item.title}" (matches exclude pattern)`);
continue;
}
const createdAt = new Date(item.created_at); const createdAt = new Date(item.created_at);
const isNew = createdAt >= cutoffDate; const isNew = createdAt >= cutoffDate;