@@ -1103,6 +1103,7 @@ class GitConfigHelper {
11031103 this.extraheaderConfigPlaceholderValue = 'AUTHORIZATION: basic ***';
11041104 this.extraheaderConfigValueRegex = '^AUTHORIZATION:';
11051105 this.persistedExtraheaderConfigValue = '';
1106+ this.backedUpCredentialFiles = [];
11061107 this.git = git;
11071108 this.workingDirectory = this.git.getWorkingDirectory();
11081109 }
@@ -1182,12 +1183,16 @@ class GitConfigHelper {
11821183 return __awaiter(this, void 0, void 0, function* () {
11831184 const serverUrl = new url_1.URL(`https://${this.getGitRemote().hostname}`);
11841185 this.extraheaderConfigKey = `http.${serverUrl.origin}/.extraheader`;
1186+ // Backup checkout@v6 credential files if they exist
1187+ yield this.hideCredentialFiles();
11851188 // Save and unset persisted extraheader credential in git config if it exists
11861189 this.persistedExtraheaderConfigValue = yield this.getAndUnset();
11871190 });
11881191 }
11891192 restorePersistedAuth() {
11901193 return __awaiter(this, void 0, void 0, function* () {
1194+ // Restore checkout@v6 credential files if they were backed up
1195+ yield this.unhideCredentialFiles();
11911196 if (this.persistedExtraheaderConfigValue) {
11921197 try {
11931198 yield this.setExtraheaderConfig(this.persistedExtraheaderConfigValue);
@@ -1224,6 +1229,48 @@ class GitConfigHelper {
12241229 yield this.gitConfigStringReplace(this.extraheaderConfigPlaceholderValue, extraheaderConfigValue);
12251230 });
12261231 }
1232+ hideCredentialFiles() {
1233+ return __awaiter(this, void 0, void 0, function* () {
1234+ // Temporarily hide checkout@v6 credential files to avoid duplicate auth headers
1235+ const runnerTemp = process.env['RUNNER_TEMP'];
1236+ if (!runnerTemp) {
1237+ return;
1238+ }
1239+ try {
1240+ const files = yield fs.promises.readdir(runnerTemp);
1241+ for (const file of files) {
1242+ if (file.startsWith('git-credentials-') && file.endsWith('.config')) {
1243+ const sourcePath = path.join(runnerTemp, file);
1244+ const backupPath = `${sourcePath}.bak`;
1245+ yield fs.promises.rename(sourcePath, backupPath);
1246+ this.backedUpCredentialFiles.push(backupPath);
1247+ core.info(`Temporarily hiding checkout credential file: ${file} (will be restored after)`);
1248+ }
1249+ }
1250+ }
1251+ catch (e) {
1252+ // If directory doesn't exist or we can't read it, just continue
1253+ core.debug(`Could not backup credential files: ${utils.getErrorMessage(e)}`);
1254+ }
1255+ });
1256+ }
1257+ unhideCredentialFiles() {
1258+ return __awaiter(this, void 0, void 0, function* () {
1259+ // Restore checkout@v6 credential files that were backed up
1260+ for (const backupPath of this.backedUpCredentialFiles) {
1261+ try {
1262+ const originalPath = backupPath.replace(/\.bak$/, '');
1263+ yield fs.promises.rename(backupPath, originalPath);
1264+ const fileName = path.basename(originalPath);
1265+ core.info(`Restored checkout credential file: ${fileName}`);
1266+ }
1267+ catch (e) {
1268+ core.warning(`Failed to restore credential file ${backupPath}: ${utils.getErrorMessage(e)}`);
1269+ }
1270+ }
1271+ this.backedUpCredentialFiles = [];
1272+ });
1273+ }
12271274 getAndUnset() {
12281275 return __awaiter(this, void 0, void 0, function* () {
12291276 let configValue = '';
0 commit comments