Compare commits

..

2 Commits

Author SHA1 Message Date
Xavier Solé Nogués
cf061dbfbf Merge d1d381abe7 into cbb722410c 2024-12-18 14:20:52 +00:00
xavisolesoft
d1d381abe7 Implement allow-path-outside-workspace 2024-12-18 10:08:23 +01:00
6 changed files with 13 additions and 3 deletions

View File

@@ -17,4 +17,4 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Publish - name: Publish
id: publish id: publish
uses: actions/publish-immutable-action@v0.0.4 uses: actions/publish-immutable-action@0.0.3

View File

@@ -48,7 +48,7 @@ jobs:
# Use `docker/build-push-action` to build (and optionally publish) the image. # Use `docker/build-push-action` to build (and optionally publish) the image.
- name: Build Docker Image (with optional Push) - name: Build Docker Image (with optional Push)
uses: docker/build-push-action@v6.10.0 uses: docker/build-push-action@v6.5.0
with: with:
context: . context: .
file: images/test-ubuntu-git.Dockerfile file: images/test-ubuntu-git.Dockerfile

View File

@@ -74,6 +74,10 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
# Relative path under $GITHUB_WORKSPACE to place the repository # Relative path under $GITHUB_WORKSPACE to place the repository
path: '' path: ''
# Allow the checked-out repository to be placed outside of the workspace
# Default: false
allow-path-outside-workspace: ''
# Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching # Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching
# Default: true # Default: true
clean: '' clean: ''

View File

@@ -54,6 +54,10 @@ inputs:
default: true default: true
path: path:
description: 'Relative path under $GITHUB_WORKSPACE to place the repository' description: 'Relative path under $GITHUB_WORKSPACE to place the repository'
allow-path-outside-workspace:
description: Allow the checked-out repository to be placed outside of the workspace.
default: false
required: false
clean: clean:
description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching' description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching'
default: true default: true

3
dist/index.js vendored
View File

@@ -1737,7 +1737,8 @@ function getInputs() {
// Repository path // Repository path
result.repositoryPath = core.getInput('path') || '.'; result.repositoryPath = core.getInput('path') || '.';
result.repositoryPath = path.resolve(githubWorkspacePath, result.repositoryPath); result.repositoryPath = path.resolve(githubWorkspacePath, result.repositoryPath);
if (!(result.repositoryPath + path.sep).startsWith(githubWorkspacePath + path.sep)) { if (!core.getInput('allow-path-outside-workspace') &&
!(result.repositoryPath + path.sep).startsWith(githubWorkspacePath + path.sep)) {
throw new Error(`Repository path '${result.repositoryPath}' is not under '${githubWorkspacePath}'`); throw new Error(`Repository path '${result.repositoryPath}' is not under '${githubWorkspacePath}'`);
} }
// Workflow repository? // Workflow repository?

View File

@@ -42,6 +42,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
result.repositoryPath result.repositoryPath
) )
if ( if (
!core.getInput('allow-path-outside-workspace') &&
!(result.repositoryPath + path.sep).startsWith( !(result.repositoryPath + path.sep).startsWith(
githubWorkspacePath + path.sep githubWorkspacePath + path.sep
) )