Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions .github/workflows/validate-pr-target-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ jobs:

// Helper function to check if a user is a bot
const isBot = (username) => {
return username === 'copilot' ||
username === 'dotnet-bot' ||
username.startsWith('app/') ||
username.includes('[bot]');
const lower = username.toLowerCase();
return lower === 'copilot' ||
lower === 'dotnet-bot' ||
lower.startsWith('app/') ||
lower.includes('[bot]');
};

// If action is 'edited', check if the base branch was actually changed
Expand All @@ -64,8 +65,14 @@ jobs:
hasWriteAccess = ['admin', 'write'].includes(permissions.permission);
console.log(`User ${triggeredBy} has permission level: ${permissions.permission}`);
} catch (error) {
// If the user cannot be found (e.g. non-user accounts like Copilot), skip
if (error.status === 404) {
console.log(`User ${triggeredBy} not found - skipping`);
return;
}
console.error('Error checking permissions:', error);
// If we can't determine permissions, assume external contributor
// If we can't determine permissions for other reasons, skip to avoid false positives
return;
}

// Check if target branch is a release branch
Expand Down
Loading