mirror of
https://forgejo.mixinet.net/actions/checkout.git
synced 2025-06-15 14:50:45 -06:00
Add a configurable SSH user
This commit is contained in:
parent
cd7d8d697e
commit
4fbc953ab8
5 changed files with 12 additions and 2 deletions
|
@ -94,6 +94,11 @@ export interface IGitSourceSettings {
|
|||
*/
|
||||
sshStrict: boolean
|
||||
|
||||
/**
|
||||
* The SSH user to login as
|
||||
*/
|
||||
sshUser: string
|
||||
|
||||
/**
|
||||
* Indicates whether to persist the credentials on disk to enable scripting authenticated git commands
|
||||
*/
|
||||
|
|
|
@ -143,6 +143,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||
result.sshKnownHosts = core.getInput('ssh-known-hosts')
|
||||
result.sshStrict =
|
||||
(core.getInput('ssh-strict') || 'true').toUpperCase() === 'TRUE'
|
||||
result.sshUser = core.getInput('ssh-user')
|
||||
|
||||
// Persist credentials
|
||||
result.persistCredentials =
|
||||
|
|
|
@ -12,7 +12,8 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
|
|||
const encodedOwner = encodeURIComponent(settings.repositoryOwner)
|
||||
const encodedName = encodeURIComponent(settings.repositoryName)
|
||||
if (settings.sshKey) {
|
||||
return `git@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`
|
||||
let user = settings.sshUser.length > 0 ? settings.sshUser : 'git'
|
||||
return `${user}@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`
|
||||
}
|
||||
|
||||
// "origin" is SCHEME://HOSTNAME[:PORT]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue