From 27a1d89941b6f2a19e52a84db599a5bc6c58104d Mon Sep 17 00:00:00 2001 From: Amiel Martin Date: Thu, 16 Sep 2021 12:22:00 -0800 Subject: [PATCH] Update src/labeler.ts Safer access of pull_request data. Co-authored-by: Josh Dales <30500472+joshdales@users.noreply.github.com> --- src/labeler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/labeler.ts b/src/labeler.ts index 93eeef7a..675e1d91 100644 --- a/src/labeler.ts +++ b/src/labeler.ts @@ -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; }