mirror of
https://github.com/actions/labeler.git
synced 2025-12-11 12:07:32 +00:00
Update src/labeler.ts
Safer access of pull_request data. Co-authored-by: Josh Dales <30500472+joshdales@users.noreply.github.com>
This commit is contained in:
@@ -216,10 +216,10 @@ function checkAll(changedFiles: string[], globs: string[]): boolean {
|
||||
|
||||
function checkBranch(glob: string): boolean {
|
||||
const matcher = new Minimatch(glob);
|
||||
const branchName = github.context.payload.pull_request!.head.ref;
|
||||
const branchName = github.context.payload.pull_request?.head.ref;
|
||||
core.debug(` checking "branch" pattern against ${branchName}`);
|
||||
core.debug(` - ${printPattern(matcher)}`);
|
||||
if (!matcher.match(branchName)) {
|
||||
if (branchName || !matcher.match(branchName)) {
|
||||
core.debug(` ${printPattern(matcher)} did not match`);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user