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 return mounts
} }
const workspacePath = process.env.GITHUB_WORKSPACE as string
for (const userVolume of userMountVolumes) { for (const userVolume of userMountVolumes) {
const sourceVolumePath = `${ let sourceVolumePath = ''
path.isAbsolute(userVolume.sourceVolumePath) if (path.isAbsolute(userVolume.sourceVolumePath)) {
? userVolume.sourceVolumePath if (!userVolume.sourceVolumePath.startsWith(workspacePath)) {
: path.join( 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, process.env.GITHUB_WORKSPACE as string,
userVolume.sourceVolumePath userVolume.sourceVolumePath
) )
}` }
mounts.push({ mounts.push({
name: POD_VOLUME_NAME, name: POD_VOLUME_NAME,