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([
|
const output = yield this.exec([
|
||||||
'config',
|
'config',
|
||||||
globalConfig ? '--global' : '--local',
|
globalConfig ? '--global' : '--local',
|
||||||
|
'--includes', // Detect configs from included files (e.g., checkout@v6)
|
||||||
'--name-only',
|
'--name-only',
|
||||||
'--get-regexp',
|
'--get-regexp',
|
||||||
configKey,
|
configKey,
|
||||||
@ -820,6 +821,7 @@ class GitCommandManager {
|
|||||||
const output = yield this.exec([
|
const output = yield this.exec([
|
||||||
'config',
|
'config',
|
||||||
'--local',
|
'--local',
|
||||||
|
'--includes', // Get configs from included files (e.g., checkout@v6)
|
||||||
'--get-regexp',
|
'--get-regexp',
|
||||||
configKey,
|
configKey,
|
||||||
configValue
|
configValue
|
||||||
@ -1205,6 +1207,15 @@ class GitConfigHelper {
|
|||||||
const basicCredential = Buffer.from(`x-access-token:${token}`, 'utf8').toString('base64');
|
const basicCredential = Buffer.from(`x-access-token:${token}`, 'utf8').toString('base64');
|
||||||
core.setSecret(basicCredential);
|
core.setSecret(basicCredential);
|
||||||
const extraheaderConfigValue = `AUTHORIZATION: basic ${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);
|
yield this.setExtraheaderConfig(extraheaderConfigValue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,6 +115,7 @@ export class GitCommandManager {
|
|||||||
[
|
[
|
||||||
'config',
|
'config',
|
||||||
globalConfig ? '--global' : '--local',
|
globalConfig ? '--global' : '--local',
|
||||||
|
'--includes', // Detect configs from included files (e.g., checkout@v6)
|
||||||
'--name-only',
|
'--name-only',
|
||||||
'--get-regexp',
|
'--get-regexp',
|
||||||
configKey,
|
configKey,
|
||||||
@ -212,6 +213,7 @@ export class GitCommandManager {
|
|||||||
const output = await this.exec([
|
const output = await this.exec([
|
||||||
'config',
|
'config',
|
||||||
'--local',
|
'--local',
|
||||||
|
'--includes', // Get configs from included files (e.g., checkout@v6)
|
||||||
'--get-regexp',
|
'--get-regexp',
|
||||||
configKey,
|
configKey,
|
||||||
configValue
|
configValue
|
||||||
|
|||||||
@ -144,6 +144,27 @@ export class GitConfigHelper {
|
|||||||
).toString('base64')
|
).toString('base64')
|
||||||
core.setSecret(basicCredential)
|
core.setSecret(basicCredential)
|
||||||
const extraheaderConfigValue = `AUTHORIZATION: basic ${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)
|
await this.setExtraheaderConfig(extraheaderConfigValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user