This commit is contained in:
Nikola Jokic
2025-12-04 16:17:11 +01:00
parent 9da01d74f1
commit fdf0659b76
3 changed files with 21 additions and 5 deletions

View File

@@ -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
)

View File

@@ -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

View File

@@ -288,6 +288,11 @@ function mergeLists<T>(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(' '))
}