mirror of https://github.com/actions/checkout
Compare commits
5 Commits
7fb5e29699
...
a6331e1c6b
| Author | SHA1 | Date |
|---|---|---|
|
|
a6331e1c6b | |
|
|
3d3c42e5aa | |
|
|
28802689a1 | |
|
|
b23eb344e8 | |
|
|
a0eb51f8ea |
|
|
@ -314,7 +314,6 @@ jobs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify auth token
|
# Verify auth token
|
||||||
git config --global --add safe.directory "*"
|
|
||||||
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
git fetch --no-tags --depth=1 origin +refs/heads/main:refs/remotes/origin/main
|
||||||
|
|
||||||
# needed to make checkout post cleanup succeed
|
# needed to make checkout post cleanup succeed
|
||||||
|
|
|
||||||
13
CHANGELOG.md
13
CHANGELOG.md
|
|
@ -1,5 +1,18 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v7.0.1
|
||||||
|
* Bump github/codeql-action from 3 to 4 by @dependabot[bot] in https://github.com/actions/checkout/pull/2475
|
||||||
|
* Bump actions/setup-node from 4 to 6 by @dependabot[bot] in https://github.com/actions/checkout/pull/2477
|
||||||
|
* Bump docker/build-push-action from 6.5.0 to 7.2.0 by @dependabot[bot] in https://github.com/actions/checkout/pull/2478
|
||||||
|
* Bump docker/login-action from 3.3.0 to 4.2.0 by @dependabot[bot] in https://github.com/actions/checkout/pull/2479
|
||||||
|
* Bump actions/checkout from 6 to 7 by @dependabot[bot] in https://github.com/actions/checkout/pull/2488
|
||||||
|
* Bump actions/upload-artifact from 4 to 7 by @dependabot[bot] in https://github.com/actions/checkout/pull/2476
|
||||||
|
* eslint 9 by @dependabot[bot] in https://github.com/actions/checkout/pull/2474
|
||||||
|
* Bump the minor-actions-dependencies group with 2 updates by @dependabot[bot] in https://github.com/actions/checkout/pull/2499
|
||||||
|
* skip running unsafe pr check if input is default by @aiqiaoy in https://github.com/actions/checkout/pull/2518
|
||||||
|
* trim only ascii whitespace for branch by @aiqiaoy in https://github.com/actions/checkout/pull/2521
|
||||||
|
* escape values passed to --unset by @aiqiaoy in https://github.com/actions/checkout/pull/2530
|
||||||
|
|
||||||
## v7.0.0
|
## v7.0.0
|
||||||
* Block checking out fork PR for pull_request_target and workflow_run by @aiqiaoy in https://github.com/actions/checkout/pull/2454
|
* Block checking out fork PR for pull_request_target and workflow_run by @aiqiaoy in https://github.com/actions/checkout/pull/2454
|
||||||
* Bump actions/publish-immutable-action from 0.0.3 to 0.0.4 in the minor-actions-dependencies group across 1 directory by @dependabot[bot] in https://github.com/actions/checkout/pull/2458
|
* Bump actions/publish-immutable-action from 0.0.3 to 0.0.4 in the minor-actions-dependencies group across 1 directory by @dependabot[bot] in https://github.com/actions/checkout/pull/2458
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@ fi
|
||||||
|
|
||||||
cd "$CHECKOUT_PATH"
|
cd "$CHECKOUT_PATH"
|
||||||
|
|
||||||
# Add safe directory for container environments
|
|
||||||
git config --global --add safe.directory "*" 2>/dev/null || true
|
|
||||||
|
|
||||||
# Show the includeIf configuration
|
# Show the includeIf configuration
|
||||||
echo "Git config includeIf entries:"
|
echo "Git config includeIf entries:"
|
||||||
git config --list --show-origin | grep -i include || true
|
git config --list --show-origin | grep -i include || true
|
||||||
|
|
|
||||||
|
|
@ -35913,7 +35913,7 @@ class GitCommandManager {
|
||||||
else {
|
else {
|
||||||
args.push(globalConfig ? '--global' : '--local');
|
args.push(globalConfig ? '--global' : '--local');
|
||||||
}
|
}
|
||||||
args.push('--unset', configKey, configValue);
|
args.push('--unset', configKey, regexp_helper_escape(configValue));
|
||||||
const output = await this.execGit(args, true);
|
const output = await this.execGit(args, true);
|
||||||
return output.exitCode === 0;
|
return output.exitCode === 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "7.0.0",
|
"version": "7.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "7.0.0",
|
"version": "7.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^3.0.1",
|
"@actions/core": "^3.0.1",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "checkout",
|
"name": "checkout",
|
||||||
"version": "7.0.0",
|
"version": "7.0.1",
|
||||||
"description": "checkout action",
|
"description": "checkout action",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
|
|
|
||||||
|
|
@ -510,7 +510,7 @@ class GitCommandManager {
|
||||||
} else {
|
} else {
|
||||||
args.push(globalConfig ? '--global' : '--local')
|
args.push(globalConfig ? '--global' : '--local')
|
||||||
}
|
}
|
||||||
args.push('--unset', configKey, configValue)
|
args.push('--unset', configKey, regexpHelper.escape(configValue))
|
||||||
|
|
||||||
const output = await this.execGit(args, true)
|
const output = await this.execGit(args, true)
|
||||||
return output.exitCode === 0
|
return output.exitCode === 0
|
||||||
|
|
|
||||||
|
|
@ -44,20 +44,14 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||||
if (git) {
|
if (git) {
|
||||||
authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
authHelper = gitAuthHelper.createAuthHelper(git, settings)
|
||||||
if (settings.setSafeDirectory) {
|
if (settings.setSafeDirectory) {
|
||||||
// Setup the repository path as a safe directory, so if we pass this into a container job with a different user it doesn't fail
|
await addSafeDirectory(settings.repositoryPath, git, authHelper)
|
||||||
// Otherwise all git commands we run in a container fail
|
const containerPath = getContainerRepositoryPath(
|
||||||
await authHelper.configureTempGlobalConfig()
|
settings.repositoryPath,
|
||||||
core.info(
|
settings.githubWorkspacePath
|
||||||
`Adding repository directory to the temporary git global config as a safe directory`
|
|
||||||
)
|
)
|
||||||
|
if (containerPath && containerPath !== settings.repositoryPath) {
|
||||||
await git
|
await addSafeDirectory(containerPath, git, authHelper)
|
||||||
.config('safe.directory', settings.repositoryPath, true, true)
|
}
|
||||||
.catch(error => {
|
|
||||||
core.info(
|
|
||||||
`Failed to initialize safe directory with error: ${error}`
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
stateHelper.setSafeDirectory()
|
stateHelper.setSafeDirectory()
|
||||||
}
|
}
|
||||||
|
|
@ -350,18 +344,7 @@ export async function cleanup(repositoryPath: string): Promise<void> {
|
||||||
const authHelper = gitAuthHelper.createAuthHelper(git)
|
const authHelper = gitAuthHelper.createAuthHelper(git)
|
||||||
try {
|
try {
|
||||||
if (stateHelper.PostSetSafeDirectory) {
|
if (stateHelper.PostSetSafeDirectory) {
|
||||||
// Setup the repository path as a safe directory, so if we pass this into a container job with a different user it doesn't fail
|
await addSafeDirectory(repositoryPath, git, authHelper)
|
||||||
// Otherwise all git commands we run in a container fail
|
|
||||||
await authHelper.configureTempGlobalConfig()
|
|
||||||
core.info(
|
|
||||||
`Adding repository directory to the temporary git global config as a safe directory`
|
|
||||||
)
|
|
||||||
|
|
||||||
await git
|
|
||||||
.config('safe.directory', repositoryPath, true, true)
|
|
||||||
.catch(error => {
|
|
||||||
core.info(`Failed to initialize safe directory with error: ${error}`)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await authHelper.removeAuth()
|
await authHelper.removeAuth()
|
||||||
|
|
@ -390,3 +373,39 @@ async function getGitCommandManager(
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addSafeDirectory(
|
||||||
|
safeDirectory: string,
|
||||||
|
git: IGitCommandManager,
|
||||||
|
authHelper: gitAuthHelper.IGitAuthHelper
|
||||||
|
): Promise<void> {
|
||||||
|
await authHelper.configureTempGlobalConfig()
|
||||||
|
core.info(`Adding '${safeDirectory}' to the git global config as a safe directory`)
|
||||||
|
await git.config('safe.directory', safeDirectory, true, true).catch(error => {
|
||||||
|
core.info(`Failed to initialize safe directory with error: ${error}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainerRepositoryPath(
|
||||||
|
repositoryPath: string,
|
||||||
|
githubWorkspace?: string
|
||||||
|
): string {
|
||||||
|
if (!githubWorkspace) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
let relativeRepositoryPath = path.relative(githubWorkspace, repositoryPath)
|
||||||
|
if (!relativeRepositoryPath || relativeRepositoryPath === '.') {
|
||||||
|
return '/github/workspace'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
relativeRepositoryPath.startsWith('..') ||
|
||||||
|
path.isAbsolute(relativeRepositoryPath)
|
||||||
|
) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
relativeRepositoryPath = relativeRepositoryPath.replace(/\\/g, '/')
|
||||||
|
return path.posix.join('/github/workspace', relativeRepositoryPath)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
export interface IGitSourceSettings {
|
export interface IGitSourceSettings {
|
||||||
|
/**
|
||||||
|
* The workflow workspace path
|
||||||
|
*/
|
||||||
|
githubWorkspacePath?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location on disk where the repository will be placed
|
* The location on disk where the repository will be placed
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
||||||
throw new Error('GITHUB_WORKSPACE not defined')
|
throw new Error('GITHUB_WORKSPACE not defined')
|
||||||
}
|
}
|
||||||
githubWorkspacePath = path.resolve(githubWorkspacePath)
|
githubWorkspacePath = path.resolve(githubWorkspacePath)
|
||||||
|
result.githubWorkspacePath = githubWorkspacePath
|
||||||
core.debug(`GITHUB_WORKSPACE = '${githubWorkspacePath}'`)
|
core.debug(`GITHUB_WORKSPACE = '${githubWorkspacePath}'`)
|
||||||
fsHelper.directoryExistsSync(githubWorkspacePath, true)
|
fsHelper.directoryExistsSync(githubWorkspacePath, true)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue