Skip to content

Commit a512284

Browse files
authored
Improve backport.yml to only check start of line and instructions for team visibility (#64915)
Before the bot reacted to the /backport command anywhere in the comment, now it needs to be at the start of the line. Additionally, if the check for repo collaborator fails print a link to the Microsoft team on GitHub to change visibility (most common failure case).
1 parent 116ee71 commit a512284

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

.github/workflows/backport.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
if (context.eventName !== "issue_comment") throw "Error: This action only works on issue_comment events.";
2323
2424
// extract the target branch name from the trigger phrase containing these characters: a-z, A-Z, digits, forward slash, dot, hyphen, underscore
25-
const regex = /\/backport to ([a-zA-Z\d\/\.\-\_]+)/;
25+
const regex = /^\/backport to ([a-zA-Z\d\/\.\-\_]+)/;
2626
target_branch = regex.exec(context.payload.comment.body);
2727
if (target_branch == null) throw "Error: No backport branch found in the trigger phrase.";
2828

eng/actions/backport/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function run() {
3939
console.log(`Verified ${comment_user} is a repo collaborator.`);
4040
} catch (error) {
4141
console.log(error);
42-
throw new BackportException(`Error: @${comment_user} is not a repo collaborator, backporting is not allowed.`);
42+
throw new BackportException(`Error: @${comment_user} is not a repo collaborator, backporting is not allowed. If you're a collaborator please make sure your Microsoft team membership visibility is set to Public on https://github.com/orgs/microsoft/people?query=${comment_user}`);
4343
}
4444

4545
try { await exec.exec(`git ls-remote --exit-code --heads origin ${target_branch}`) } catch { throw new BackportException(`Error: The specified backport target branch ${target_branch} wasn't found in the repo.`); }

0 commit comments

Comments
 (0)