mirror of
https://github.com/actions/runner-container-hooks.git
synced 2025-12-14 08:36:45 +00:00
Fix event.json not being copied to /github/workflow in kubernetes-novolume mode (#287)
In run-script-step, the _temp directory was being copied to the workflow pod, but the _github_home and _github_workflow directories were not being moved from their temporary location to the /github directory structure where they are expected by GitHub Actions. This caused event.json to be missing at /github/workflow/event.json, breaking actions that depend on GITHUB_EVENT_PATH. The fix adds a setup step that copies _github_home and _github_workflow from /__w/_temp/ to /github/ after copying the temp directory to the pod, matching the behavior of run-container-step and prepareJobScript. Uses cp -r instead of symlinks to avoid symlink validation errors when copying files back from the pod to the runner.
This commit is contained in:
@@ -6,6 +6,7 @@ import { execCpFromPod, execCpToPod, execPodStep } from '../k8s'
|
|||||||
import { writeRunScript, sleep, listDirAllCommand } from '../k8s/utils'
|
import { writeRunScript, sleep, listDirAllCommand } from '../k8s/utils'
|
||||||
import { JOB_CONTAINER_NAME } from './constants'
|
import { JOB_CONTAINER_NAME } from './constants'
|
||||||
import { dirname } from 'path'
|
import { dirname } from 'path'
|
||||||
|
import * as shlex from 'shlex'
|
||||||
|
|
||||||
export async function runScriptStep(
|
export async function runScriptStep(
|
||||||
args: RunScriptStepArgs,
|
args: RunScriptStepArgs,
|
||||||
@@ -26,6 +27,23 @@ export async function runScriptStep(
|
|||||||
const runnerTemp = `${workdir}/_temp`
|
const runnerTemp = `${workdir}/_temp`
|
||||||
await execCpToPod(state.jobPod, runnerTemp, containerTemp)
|
await execCpToPod(state.jobPod, runnerTemp, containerTemp)
|
||||||
|
|
||||||
|
// Copy GitHub directories from temp to /github
|
||||||
|
const setupCommands = [
|
||||||
|
'mkdir -p /github',
|
||||||
|
'cp -r /__w/_temp/_github_home /github/home',
|
||||||
|
'cp -r /__w/_temp/_github_workflow /github/workflow'
|
||||||
|
]
|
||||||
|
|
||||||
|
try {
|
||||||
|
await execPodStep(
|
||||||
|
['sh', '-c', shlex.quote(setupCommands.join(' && '))],
|
||||||
|
state.jobPod,
|
||||||
|
JOB_CONTAINER_NAME
|
||||||
|
)
|
||||||
|
} catch (err) {
|
||||||
|
core.debug(`Failed to copy GitHub directories: ${JSON.stringify(err)}`)
|
||||||
|
}
|
||||||
|
|
||||||
// Execute the entrypoint script
|
// Execute the entrypoint script
|
||||||
args.entryPoint = 'sh'
|
args.entryPoint = 'sh'
|
||||||
args.entryPointArgs = ['-e', containerPath]
|
args.entryPointArgs = ['-e', containerPath]
|
||||||
|
|||||||
Reference in New Issue
Block a user