Skip to content

kubernetes-novolume mode: event.json not copied to /github/workflow (regression from #293) #330

@zarko-a

Description

@zarko-a

Description

In kubernetes-novolume mode, it seems that GITHUB_EVENT_PATH (/github/workflow/event.json) is not available inside job containers. Any action that reads the event payload fails.

This was previously reported and fixed in #286 / #287. However, it seems that #293 ("Reduce the amount of data copied to the workflow pod") inadvertently removed the fix by replacing the explicit /github/workflow copy with a merge strategy that only handles _temp directories.

In run-script-step.ts, #287 added:

const setupCommands = [
    'mkdir -p /github',
    'cp -r /__w/_temp/_github_home /github/home',
    'cp -r /__w/_temp/_github_workflow /github/workflow'
]

It seems #293 replaced the entire block with a _temp_pre_temp merge strategy that no longer copies _github_home or _github_workflow to /github/.

Reproduction

Any workflow using kubernetes-novolume mode with a container: job that reads event context will fail.

Logs

From a failing pull_request workflow run using ARC 0.14.0 in kubernetes-novolume mode:

GITHUB_EVENT_PATH /github/workflow/event.json does not exist
GITHUB_EVENT_PATH /github/workflow/event.json does not exist
##[error]Action failed with error: undefined is not an object (evaluating 'payload.pull_request.number')
##[error]Executing the custom container implementation failed. Please contact your self hosted runner administrator.

Suggested Fix

Restore the /github/workflow copy in run-script-step.ts after the temp-directory merge succeeds and before the entrypoint script executes:

diff --git a/packages/k8s/src/hooks/run-script-step.ts b/packages/k8s/src/hooks/run-script-step.ts
index 1db2bb2..97675fb 100644
--- a/packages/k8s/src/hooks/run-script-step.ts
+++ b/packages/k8s/src/hooks/run-script-step.ts
@@ -71,6 +71,26 @@ export async function runScriptStep(
     throw new Error(`failed to merge temp dirs: ${message}`)
   }
 
+  // Copy GitHub home and workflow directories to /github on the job pod
+  // so that GITHUB_EVENT_PATH (/github/workflow/event.json) is available
+  try {
+    await execPodStep(
+      [
+        'sh',
+        '-c',
+        'mkdir -p /github && cp -R /__w/_temp/_github_home /github/home && cp -R /__w/_temp/_github_workflow /github/workflow'
+      ],
+      state.jobPod,
+      JOB_CONTAINER_NAME
+    )
+  } catch (err) {
+    core.debug(
+      `Failed to copy GitHub directories to /github: ${JSON.stringify(err)}`
+    )
+    const message = (err as any)?.response?.body?.message || err
+    throw new Error(`failed to copy GitHub directories: ${message}`)
+  }
+
   // Execute the entrypoint script
   args.entryPoint = 'sh'
   args.entryPointArgs = ['-e', containerPath]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions