File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ export const getCommitOid = async function (
109109export const determineMergeBaseCommitOid = async function ( ) : Promise <
110110 string | undefined
111111> {
112- if ( process . env . GITHUB_EVENT_NAME !== "pull_request" ) {
112+ if ( workflowEventName ( ) !== "pull_request" ) {
113113 return undefined ;
114114 }
115115
@@ -821,9 +821,21 @@ export async function sendStatusReport<S extends StatusReportBase>(
821821 }
822822}
823823
824+ export function workflowEventName ( ) {
825+ // If the original event is dynamic CODESCANNING_EVENT_NAME will contain the right info (push/pull_request)
826+ if ( process . env [ "GITHUB_EVENT_NAME" ] === "dynamic" ) {
827+ const value = process . env [ "CODESCANNING_EVENT_NAME" ] ;
828+ if ( value === undefined || value . length === 0 ) {
829+ return process . env [ "GITHUB_EVENT_NAME" ] ;
830+ }
831+ return value
832+ }
833+ return process . env [ "GITHUB_EVENT_NAME" ] ;
834+ }
835+
824836// Was the workflow run triggered by a `push` event, for example as opposed to a `pull_request` event.
825837function workflowIsTriggeredByPushEvent ( ) {
826- return process . env [ "GITHUB_EVENT_NAME" ] === "push" ;
838+ return workflowEventName ( ) === "push" ;
827839}
828840
829841// Is dependabot the actor that triggered the current workflow run.
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export async function downloadTrapCaches(
9191 let baseSha = "unknown" ;
9292 const eventPath = process . env . GITHUB_EVENT_PATH ;
9393 if (
94- process . env . GITHUB_EVENT_NAME === "pull_request" &&
94+ actionsUtil . workflowEventName ( ) === "pull_request" &&
9595 eventPath !== undefined
9696 ) {
9797 const event = JSON . parse ( fs . readFileSync ( path . resolve ( eventPath ) , "utf-8" ) ) ;
Original file line number Diff line number Diff line change @@ -325,7 +325,7 @@ export function buildPayload(
325325 gitHubVersion . type !== util . GitHubVariant . GHES ||
326326 semver . satisfies ( gitHubVersion . version , `>=3.1` )
327327 ) {
328- if ( process . env . GITHUB_EVENT_NAME === "pull_request" ) {
328+ if ( actionsUtil . workflowEventName ( ) === "pull_request" ) {
329329 if (
330330 commitOid === util . getRequiredEnvParam ( "GITHUB_SHA" ) &&
331331 mergeBaseCommitOid
You can’t perform that action at this time.
0 commit comments