mirror of
https://github.com/actions/checkout.git
synced 2025-10-15 20:52:58 +08:00
.
This commit is contained in:
@@ -318,19 +318,24 @@ class GitAuthHelper {
|
|||||||
} else {
|
} else {
|
||||||
// For local config, use includeIf.gitdir to match the .git directory.
|
// For local config, use includeIf.gitdir to match the .git directory.
|
||||||
// Configure for both host and container paths to support Docker container actions.
|
// Configure for both host and container paths to support Docker container actions.
|
||||||
const gitDir = path.join(this.git.getWorkingDirectory(), '.git')
|
let gitDir = path.join(this.git.getWorkingDirectory(), '.git')
|
||||||
|
// Use forward slashes for git config, even on Windows
|
||||||
|
gitDir = gitDir.replace(/\\/g, '/')
|
||||||
const hostIncludeKey = `includeIf.gitdir:${gitDir}.path`
|
const hostIncludeKey = `includeIf.gitdir:${gitDir}.path`
|
||||||
await this.git.config(hostIncludeKey, credentialsConfigPath)
|
await this.git.config(hostIncludeKey, credentialsConfigPath)
|
||||||
this.credentialsIncludeKeys.push(hostIncludeKey)
|
this.credentialsIncludeKeys.push(hostIncludeKey)
|
||||||
|
|
||||||
// Configure for container scenario where paths are mapped to fixed locations
|
// Configure for container scenario where paths are mapped to fixed locations
|
||||||
const githubWorkspace = process.env['GITHUB_WORKSPACE']
|
const githubWorkspace = process.env['GITHUB_WORKSPACE']
|
||||||
if (githubWorkspace) {
|
assert.ok(githubWorkspace, 'GITHUB_WORKSPACE is not defined')
|
||||||
|
|
||||||
// Calculate the relative path of the working directory from GITHUB_WORKSPACE
|
// Calculate the relative path of the working directory from GITHUB_WORKSPACE
|
||||||
const workingDirectory = this.git.getWorkingDirectory()
|
const workingDirectory = this.git.getWorkingDirectory()
|
||||||
const relativePath = path.relative(githubWorkspace, workingDirectory)
|
let relativePath = path.relative(githubWorkspace, workingDirectory)
|
||||||
|
|
||||||
// Container paths: GITHUB_WORKSPACE -> /github/workspace, RUNNER_TEMP -> /github/runner_temp
|
// Container paths: GITHUB_WORKSPACE -> /github/workspace, RUNNER_TEMP -> /github/runner_temp
|
||||||
|
// Use forward slashes for git config
|
||||||
|
relativePath = relativePath.replace(/\\/g, '/')
|
||||||
const containerGitDir = path.posix.join(
|
const containerGitDir = path.posix.join(
|
||||||
'/github/workspace',
|
'/github/workspace',
|
||||||
relativePath,
|
relativePath,
|
||||||
@@ -346,7 +351,6 @@ class GitAuthHelper {
|
|||||||
this.credentialsIncludeKeys.push(containerIncludeKey)
|
this.credentialsIncludeKeys.push(containerIncludeKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async replaceTokenPlaceholder(configPath: string): Promise<void> {
|
private async replaceTokenPlaceholder(configPath: string): Promise<void> {
|
||||||
assert.ok(configPath, 'configPath is not defined')
|
assert.ok(configPath, 'configPath is not defined')
|
||||||
|
Reference in New Issue
Block a user