mirror of
https://github.com/docker/metadata-action.git
synced 2025-06-24 03:37:59 +02:00
Fix pull_request_target
event
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
14
src/meta.ts
14
src/meta.ts
@ -27,6 +27,12 @@ export class Meta {
|
||||
private readonly date: Date;
|
||||
|
||||
constructor(inputs: Inputs, context: Context, repo: ReposGetResponseData) {
|
||||
// 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;
|
||||
@ -191,15 +197,11 @@ export class Meta {
|
||||
}
|
||||
|
||||
private procRefPr(version: Version, tag: tcl.Tag): Version {
|
||||
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');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user