Skip to content

Commit

Permalink
fix undefined base_ref for some events
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Apr 21, 2022
1 parent d9bed0b commit 3f44870
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/meta.ts
Expand Up @@ -366,11 +366,11 @@ export class Meta {
return ctx.sha.substr(0, 7);
},
base_ref: function () {
if (/^refs\/tags\//.test(ctx.ref)) {
return ctx.payload?.base_ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
if (/^refs\/tags\//.test(ctx.ref) && ctx.payload?.base_ref != undefined) {
return ctx.payload.base_ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
}
if (/^refs\/pull\//.test(ctx.ref)) {
return ctx.payload?.pull_request?.base?.ref;
if (/^refs\/pull\//.test(ctx.ref) && ctx.payload?.pull_request?.base?.ref != undefined) {
return ctx.payload.pull_request.base.ref;
}
return '';
},
Expand Down

0 comments on commit 3f44870

Please sign in to comment.