Fix pull_request_target event

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-05-25 18:45:23 +02:00
parent 013e892d4a
commit 85f4f732f2
3 changed files with 80 additions and 40 deletions

13
dist/index.js generated vendored
View File

@ -382,6 +382,11 @@ const fcl = __importStar(__webpack_require__(3716));
const core = __importStar(__webpack_require__(2186));
class Meta {
constructor(inputs, context, repo) {
// Needs to override Git reference with pr ref instead of upstream branch ref
// for pull_request_target event
if (/pull_request_target/.test(context.eventName)) {
context.ref = `refs/pull/${context.payload.number}/merge`;
}
this.inputs = inputs;
this.context = context;
this.repo = repo;
@ -531,14 +536,10 @@ class Meta {
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? true : this.flavor.latest == 'true');
}
procRefPr(version, tag) {
let ref = this.context.ref;
if (/pull_request_target/.test(this.context.eventName)) {
ref = `refs/pull/${this.context.payload.number}/merge`;
}
if (!/^refs\/pull\//.test(ref)) {
if (!/^refs\/pull\//.test(this.context.ref)) {
return version;
}
const vraw = this.setValue(ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, ''), tag);
const vraw = this.setValue(this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, ''), tag);
return Meta.setVersion(version, vraw, this.flavor.latest == 'auto' ? false : this.flavor.latest == 'true');
}
procEdge(version, tag) {