fix: double auth with checkout v6
Signed-off-by: lucasew <lucas59356@gmail.com>
This commit is contained in:
parent
b4733b9419
commit
122cf7516b
11
dist/index.js
vendored
11
dist/index.js
vendored
@ -738,6 +738,7 @@ class GitCommandManager {
|
||||
const output = yield this.exec([
|
||||
'config',
|
||||
globalConfig ? '--global' : '--local',
|
||||
'--includes', // Detect configs from included files (e.g., checkout@v6)
|
||||
'--name-only',
|
||||
'--get-regexp',
|
||||
configKey,
|
||||
@ -820,6 +821,7 @@ class GitCommandManager {
|
||||
const output = yield this.exec([
|
||||
'config',
|
||||
'--local',
|
||||
'--includes', // Get configs from included files (e.g., checkout@v6)
|
||||
'--get-regexp',
|
||||
configKey,
|
||||
configValue
|
||||
@ -1205,6 +1207,15 @@ class GitConfigHelper {
|
||||
const basicCredential = Buffer.from(`x-access-token:${token}`, 'utf8').toString('base64');
|
||||
core.setSecret(basicCredential);
|
||||
const extraheaderConfigValue = `AUTHORIZATION: basic ${basicCredential}`;
|
||||
// Check if the same token is already configured (e.g., by checkout@v6)
|
||||
// If so, skip reconfiguration to avoid duplicate headers
|
||||
if (yield this.git.configExists(this.extraheaderConfigKey, this.extraheaderConfigValueRegex)) {
|
||||
const existingValue = yield this.git.getConfigValue(this.extraheaderConfigKey, this.extraheaderConfigValueRegex);
|
||||
if (existingValue === extraheaderConfigValue) {
|
||||
core.info('Git credentials already configured with the same token, skipping reconfiguration');
|
||||
return;
|
||||
}
|
||||
}
|
||||
yield this.setExtraheaderConfig(extraheaderConfigValue);
|
||||
});
|
||||
}
|
||||
|
||||
@ -115,6 +115,7 @@ export class GitCommandManager {
|
||||
[
|
||||
'config',
|
||||
globalConfig ? '--global' : '--local',
|
||||
'--includes', // Detect configs from included files (e.g., checkout@v6)
|
||||
'--name-only',
|
||||
'--get-regexp',
|
||||
configKey,
|
||||
@ -212,6 +213,7 @@ export class GitCommandManager {
|
||||
const output = await this.exec([
|
||||
'config',
|
||||
'--local',
|
||||
'--includes', // Get configs from included files (e.g., checkout@v6)
|
||||
'--get-regexp',
|
||||
configKey,
|
||||
configValue
|
||||
|
||||
@ -144,6 +144,27 @@ export class GitConfigHelper {
|
||||
).toString('base64')
|
||||
core.setSecret(basicCredential)
|
||||
const extraheaderConfigValue = `AUTHORIZATION: basic ${basicCredential}`
|
||||
|
||||
// Check if the same token is already configured (e.g., by checkout@v6)
|
||||
// If so, skip reconfiguration to avoid duplicate headers
|
||||
if (
|
||||
await this.git.configExists(
|
||||
this.extraheaderConfigKey,
|
||||
this.extraheaderConfigValueRegex
|
||||
)
|
||||
) {
|
||||
const existingValue = await this.git.getConfigValue(
|
||||
this.extraheaderConfigKey,
|
||||
this.extraheaderConfigValueRegex
|
||||
)
|
||||
if (existingValue === extraheaderConfigValue) {
|
||||
core.info(
|
||||
'Git credentials already configured with the same token, skipping reconfiguration'
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
await this.setExtraheaderConfig(extraheaderConfigValue)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user