diff --git a/packages/k8s/src/hooks/run-script-step.ts b/packages/k8s/src/hooks/run-script-step.ts index d3a6626..2c1cb41 100644 --- a/packages/k8s/src/hooks/run-script-step.ts +++ b/packages/k8s/src/hooks/run-script-step.ts @@ -26,7 +26,20 @@ export async function runScriptStep( const runnerTemp = `${workdir}/_temp` const containerTemp = '/__w/_temp' const containerTempSrc = '/__w/_temp_pre' - // Stage runner temp inside container, then merge into /__w/_temp + // Ensure base and staging dirs exist before copying + try { + await execPodStep( + [ + 'sh', + '-c', + 'mkdir -p /__w && mkdir -p /__w/_temp && mkdir -p /__w/_temp_pre' + ], + state.jobPod, + JOB_CONTAINER_NAME + ) + } catch (err) { + core.debug(`Failed to create temp dirs in container: ${JSON.stringify(err)}`) + } await execCpToPod(state.jobPod, runnerTemp, containerTempSrc) // Copy GitHub directories from temp to /github @@ -46,7 +59,7 @@ export async function runScriptStep( try { await execPodStep( - ['sh', '-c', shlex.quote(mergeCommands.join(' && '))], + ['sh', '-c', mergeCommands.join(' && ')], state.jobPod, JOB_CONTAINER_NAME ) diff --git a/packages/k8s/src/k8s/index.ts b/packages/k8s/src/k8s/index.ts index 062dde4..ae773da 100644 --- a/packages/k8s/src/k8s/index.ts +++ b/packages/k8s/src/k8s/index.ts @@ -342,7 +342,6 @@ export async function execCalculateOutputHashSorted( const hash = createHash('sha256') hash.update(sortedOutput) - console.log(`sortedOutput: ${sortedOutput}`) return hash.digest('hex') } @@ -371,7 +370,6 @@ export async function localCalculateOutputHashSorted( const hash = createHash('sha256') hash.update(sortedOutput) - console.log(`sortedOutput: ${sortedOutput}`) resolve(hash.digest('hex')) } else { reject(new Error(`child process exited with code ${code}`)) @@ -833,7 +831,7 @@ export async function isPodContainerAlpine( [ 'sh', '-c', - `'[ $(cat /etc/*release* | grep -i -e "^ID=*alpine*" -c) != 0 ] || exit 1'` + `[ $(cat /etc/*release* | grep -i -e "^ID=*alpine*" -c) != 0 ] || exit 1` ], podName, containerName diff --git a/packages/k8s/src/k8s/utils.ts b/packages/k8s/src/k8s/utils.ts index 9116919..ebb5a23 100644 --- a/packages/k8s/src/k8s/utils.ts +++ b/packages/k8s/src/k8s/utils.ts @@ -288,6 +288,11 @@ function mergeLists(base?: T[], from?: T[]): T[] { } export function fixArgs(args: string[]): string[] { + // Preserve shell command strings passed via `sh -c` without re-tokenizing. + // Retokenizing would split the script into multiple args, breaking `sh -c`. + if (args.length >= 2 && args[0] === 'sh' && args[1] === '-c') { + return args + } return shlex.split(args.join(' ')) }