mirror of
https://code.forgejo.org/actions/checkout.git
synced 2024-11-25 12:01:20 +01:00
Set user.signingKey
to ssh-key
This commit is contained in:
parent
8f4b7f8486
commit
b8a48d8f8e
3 changed files with 9 additions and 1 deletions
|
@ -295,6 +295,10 @@ describe('git-auth-helper tests', () => {
|
||||||
'core.sshCommand',
|
'core.sshCommand',
|
||||||
expectedSshCommand
|
expectedSshCommand
|
||||||
)
|
)
|
||||||
|
expect(git.config).toHaveBeenCalledWith(
|
||||||
|
'user.signingKey',
|
||||||
|
actualKeyPath
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const configureAuth_writesExplicitKnownHosts = 'writes explicit known hosts'
|
const configureAuth_writesExplicitKnownHosts = 'writes explicit known hosts'
|
||||||
|
|
4
dist/index.js
vendored
4
dist/index.js
vendored
|
@ -148,6 +148,7 @@ const urlHelper = __importStar(__nccwpck_require__(9437));
|
||||||
const v4_1 = __importDefault(__nccwpck_require__(824));
|
const v4_1 = __importDefault(__nccwpck_require__(824));
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
const SSH_COMMAND_KEY = 'core.sshCommand';
|
const SSH_COMMAND_KEY = 'core.sshCommand';
|
||||||
|
const SIGNING_KEY = 'user.signingKey';
|
||||||
function createAuthHelper(git, settings) {
|
function createAuthHelper(git, settings) {
|
||||||
return new GitAuthHelper(git, settings);
|
return new GitAuthHelper(git, settings);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +306,7 @@ class GitAuthHelper {
|
||||||
this.sshKeyPath = path.join(runnerTemp, uniqueId);
|
this.sshKeyPath = path.join(runnerTemp, uniqueId);
|
||||||
stateHelper.setSshKeyPath(this.sshKeyPath);
|
stateHelper.setSshKeyPath(this.sshKeyPath);
|
||||||
yield fs.promises.mkdir(runnerTemp, { recursive: true });
|
yield fs.promises.mkdir(runnerTemp, { recursive: true });
|
||||||
yield fs.promises.writeFile(this.sshKeyPath, this.settings.sshKey.trim() + '\n', { mode: 0o600 });
|
yield fs.promises.writeFile(this.sshKeyPath, `${this.settings.sshKey.trim()}\n`, { mode: 0o600 });
|
||||||
// Remove inherited permissions on Windows
|
// Remove inherited permissions on Windows
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
const icacls = yield io.which('icacls.exe');
|
const icacls = yield io.which('icacls.exe');
|
||||||
|
@ -346,6 +347,7 @@ class GitAuthHelper {
|
||||||
// Configure core.sshCommand
|
// Configure core.sshCommand
|
||||||
if (this.settings.persistCredentials) {
|
if (this.settings.persistCredentials) {
|
||||||
yield this.git.config(SSH_COMMAND_KEY, this.sshCommand);
|
yield this.git.config(SSH_COMMAND_KEY, this.sshCommand);
|
||||||
|
yield this.git.config(SIGNING_KEY, this.sshKeyPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {IGitSourceSettings} from './git-source-settings'
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32'
|
const IS_WINDOWS = process.platform === 'win32'
|
||||||
const SSH_COMMAND_KEY = 'core.sshCommand'
|
const SSH_COMMAND_KEY = 'core.sshCommand'
|
||||||
|
const SIGNING_KEY = 'user.signingKey'
|
||||||
|
|
||||||
export interface IGitAuthHelper {
|
export interface IGitAuthHelper {
|
||||||
configureAuth(): Promise<void>
|
configureAuth(): Promise<void>
|
||||||
|
@ -269,6 +270,7 @@ class GitAuthHelper {
|
||||||
// Configure core.sshCommand
|
// Configure core.sshCommand
|
||||||
if (this.settings.persistCredentials) {
|
if (this.settings.persistCredentials) {
|
||||||
await this.git.config(SSH_COMMAND_KEY, this.sshCommand)
|
await this.git.config(SSH_COMMAND_KEY, this.sshCommand)
|
||||||
|
await this.git.config(SIGNING_KEY, this.sshKeyPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue