When running on a schedule, make a better guess about whether we're analyzing the default branch.
This commit is contained in:
parent
92c650bfbd
commit
5960bffd3f
6 changed files with 59 additions and 10 deletions
|
|
@ -860,17 +860,23 @@ function getWorkflowEvent(): any {
|
|||
}
|
||||
}
|
||||
|
||||
function removeRefsHeadsPrefix(ref: string): string {
|
||||
return ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref;
|
||||
}
|
||||
|
||||
// Is the version of the repository we are currently analyzing from the default branch,
|
||||
// or alternatively from another branch or a pull request.
|
||||
export async function isAnalyzingDefaultBranch(): Promise<boolean> {
|
||||
// Get the current ref and trim and refs/heads/ prefix
|
||||
let currentRef = await getRef();
|
||||
currentRef = currentRef.startsWith("refs/heads/")
|
||||
? currentRef.slice("refs/heads/".length)
|
||||
: currentRef;
|
||||
currentRef = removeRefsHeadsPrefix(currentRef);
|
||||
|
||||
const event = getWorkflowEvent();
|
||||
const defaultBranch = event?.repository?.default_branch;
|
||||
let defaultBranch = event?.repository?.default_branch;
|
||||
|
||||
if (process.env.GITHUB_EVENT_NAME === "schedule") {
|
||||
defaultBranch = removeRefsHeadsPrefix(getRequiredEnvParam("GITHUB_REF"));
|
||||
}
|
||||
|
||||
return currentRef === defaultBranch;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue