Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement allow-path-outside-workspace #2009

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Implement allow-path-outside-workspace
  • Loading branch information
xavisolesoft committed Dec 18, 2024
commit d1d381abe720cf316aa45d143cebc9dadf38440d
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
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
# Default: true
clean: ''
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -54,6 +54,10 @@ inputs:
default: true
path:
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:
description: 'Whether to execute `git clean -ffdx && git reset --hard HEAD` before fetching'
default: true
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1737,7 +1737,8 @@ function getInputs() {
// Repository path
result.repositoryPath = core.getInput('path') || '.';
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}'`);
}
// Workflow repository?
1 change: 1 addition & 0 deletions src/input-helper.ts
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
result.repositoryPath
)
if (
!core.getInput('allow-path-outside-workspace') &&
!(result.repositoryPath + path.sep).startsWith(
githubWorkspacePath + path.sep
)