fix undefined base_ref for some events

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-04-25 13:43:05 +02:00
parent 89bf6c030f
commit 7d7a22a682
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 6 additions and 6 deletions

2
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -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 '';
},