From d9b320ec703c510de925b29ba1e7e0ae32e2b6d3 Mon Sep 17 00:00:00 2001 From: eric sciple Date: Tue, 14 Oct 2025 18:39:36 +0000 Subject: [PATCH] . --- src/git-auth-helper.ts | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts index 216e8b1..9b8131d 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -318,33 +318,37 @@ class GitAuthHelper { } else { // For local config, use includeIf.gitdir to match the .git directory. // 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` await this.git.config(hostIncludeKey, credentialsConfigPath) this.credentialsIncludeKeys.push(hostIncludeKey) // Configure for container scenario where paths are mapped to fixed locations const githubWorkspace = process.env['GITHUB_WORKSPACE'] - if (githubWorkspace) { - // Calculate the relative path of the working directory from GITHUB_WORKSPACE - const workingDirectory = this.git.getWorkingDirectory() - const relativePath = path.relative(githubWorkspace, workingDirectory) + assert.ok(githubWorkspace, 'GITHUB_WORKSPACE is not defined') + + // Calculate the relative path of the working directory from GITHUB_WORKSPACE + const workingDirectory = this.git.getWorkingDirectory() + let relativePath = path.relative(githubWorkspace, workingDirectory) - // Container paths: GITHUB_WORKSPACE -> /github/workspace, RUNNER_TEMP -> /github/runner_temp - const containerGitDir = path.posix.join( - '/github/workspace', - relativePath, - '.git' - ) - const containerCredentialsPath = path.posix.join( - '/github/runner_temp', - path.basename(credentialsConfigPath) - ) + // 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( + '/github/workspace', + relativePath, + '.git' + ) + const containerCredentialsPath = path.posix.join( + '/github/runner_temp', + path.basename(credentialsConfigPath) + ) - const containerIncludeKey = `includeIf.gitdir:${containerGitDir}.path` - await this.git.config(containerIncludeKey, containerCredentialsPath) - this.credentialsIncludeKeys.push(containerIncludeKey) - } + const containerIncludeKey = `includeIf.gitdir:${containerGitDir}.path` + await this.git.config(containerIncludeKey, containerCredentialsPath) + this.credentialsIncludeKeys.push(containerIncludeKey) } }