7 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,11 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
62
62
# Default: true
63
63
ssh-strict : ' '
64
64
65
+ # The user to use when connecting to the remote SSH host. By default 'git' is
66
+ # used.
67
+ # Default: git
68
+ ssh-user : ' '
69
+
65
70
# Whether to configure the token or SSH key with the local git config
66
71
# Default: true
67
72
persist-credentials : ' '
Original file line number Diff line number Diff line change @@ -821,6 +821,7 @@ async function setup(testName: string): Promise<void> {
821
821
sshKey : sshPath ? 'some ssh private key' : '' ,
822
822
sshKnownHosts : '' ,
823
823
sshStrict : true ,
824
+ sshUser : '' ,
824
825
workflowOrganizationId : 123456 ,
825
826
setSafeDirectory : true ,
826
827
githubServerUrl : githubServerUrl
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ inputs:
45
45
and `CheckHostIP=no` to the SSH command line. Use the input `ssh-known-hosts` to
46
46
configure additional hosts.
47
47
default : true
48
+ ssh-user :
49
+ description : >
50
+ The user to use when connecting to the remote SSH host. By default 'git' is used.
51
+ default : git
48
52
persist-credentials :
49
53
description : ' Whether to configure the token or SSH key with the local git config'
50
54
default : true
Original file line number Diff line number Diff line change @@ -1798,6 +1798,7 @@ function getInputs() {
1798
1798
result.sshKnownHosts = core.getInput('ssh-known-hosts');
1799
1799
result.sshStrict =
1800
1800
(core.getInput('ssh-strict') || 'true').toUpperCase() === 'TRUE';
1801
+ result.sshUser = core.getInput('ssh-user');
1801
1802
// Persist credentials
1802
1803
result.persistCredentials =
1803
1804
(core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE';
@@ -2400,7 +2401,8 @@ function getFetchUrl(settings) {
2400
2401
const encodedOwner = encodeURIComponent(settings.repositoryOwner);
2401
2402
const encodedName = encodeURIComponent(settings.repositoryName);
2402
2403
if (settings.sshKey) {
2403
- return `git@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`;
2404
+ const user = settings.sshUser.length > 0 ? settings.sshUser : 'git';
2405
+ return `${user}@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`;
2404
2406
}
2405
2407
// "origin" is SCHEME://HOSTNAME[:PORT]
2406
2408
return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`;
Original file line number Diff line number Diff line change @@ -94,6 +94,11 @@ export interface IGitSourceSettings {
94
94
*/
95
95
sshStrict : boolean
96
96
97
+ /**
98
+ * The SSH user to login as
99
+ */
100
+ sshUser : string
101
+
97
102
/**
98
103
* Indicates whether to persist the credentials on disk to enable scripting authenticated git commands
99
104
*/
Original file line number Diff line number Diff line change @@ -143,6 +143,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
143
143
result . sshKnownHosts = core . getInput ( 'ssh-known-hosts' )
144
144
result . sshStrict =
145
145
( core . getInput ( 'ssh-strict' ) || 'true' ) . toUpperCase ( ) === 'TRUE'
146
+ result . sshUser = core . getInput ( 'ssh-user' )
146
147
147
148
// Persist credentials
148
149
result . persistCredentials =
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
12
12
const encodedOwner = encodeURIComponent ( settings . repositoryOwner )
13
13
const encodedName = encodeURIComponent ( settings . repositoryName )
14
14
if ( settings . sshKey ) {
15
- return `git@${ serviceUrl . hostname } :${ encodedOwner } /${ encodedName } .git`
15
+ const user = settings . sshUser . length > 0 ? settings . sshUser : 'git'
16
+ return `${ user } @${ serviceUrl . hostname } :${ encodedOwner } /${ encodedName } .git`
16
17
}
17
18
18
19
// "origin" is SCHEME://HOSTNAME[:PORT]
0 commit comments