Skip to content

Commit ee5bd2a

Browse files
committed
Fix: Fix PR flow on pull_request_target
1 parent 4049d86 commit ee5bd2a

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

dist/index.js

Lines changed: 5 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/copybaraAction.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ export class CopybaraAction {
2424

2525
getCurrentBranch() {
2626
if (!this.current.branch) {
27-
let ref = "";
28-
if (context.payload.pull_request && /^refs\/heads\//.test(context.payload.pull_request.base.ref))
29-
ref = context.payload.pull_request.base.ref;
30-
else if (/^refs\/heads\//.test(context.ref)) ref = context.ref;
31-
else throw `Cannot determine head branch from ${context.payload.base_ref} and ${context.ref}`;
32-
this.current.branch = ref.replace(/^refs\/heads\//, "");
27+
if (context.payload.pull_request && context.payload.pull_request.base.ref)
28+
this.current.branch = context.payload.pull_request.base.ref;
29+
else if (/^refs\/heads\//.test(context.ref)) this.current.branch = context.ref.replace(/^refs\/heads\//, "");
30+
else throw `Cannot determine head branch from ${context.payload.pull_request?.base.ref} and ${context.ref}`;
3331
}
3432
core.debug(`Current branch is ${this.current.branch}`);
3533
return this.current.branch;

0 commit comments

Comments
 (0)