user volume mount fix based on workspacePath

This commit is contained in:
Nikola Jokic
2022-06-07 16:47:05 +02:00
parent ddf09ad7bd
commit 3ba45d3d7e

View File

@@ -43,15 +43,22 @@ export function containerVolumes(
return mounts
}
const workspacePath = process.env.GITHUB_WORKSPACE as string
for (const userVolume of userMountVolumes) {
const sourceVolumePath = `${
path.isAbsolute(userVolume.sourceVolumePath)
? userVolume.sourceVolumePath
: path.join(
let sourceVolumePath = ''
if (path.isAbsolute(userVolume.sourceVolumePath)) {
if (!userVolume.sourceVolumePath.startsWith(workspacePath)) {
throw new Error(
'absolute path volume mounts outside of the work folder are not supported'
)
}
sourceVolumePath = userVolume.sourceVolumePath
} else {
sourceVolumePath = path.join(
process.env.GITHUB_WORKSPACE as string,
userVolume.sourceVolumePath
)
}`
}
mounts.push({
name: POD_VOLUME_NAME,