File tree Expand file tree Collapse file tree 7 files changed +21
-2
lines changed
Expand file tree Collapse file tree 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/
6262 # Default: true
6363 ssh-strict : ' '
6464
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+
6570 # Whether to configure the token or SSH key with the local git config
6671 # Default: true
6772 persist-credentials : ' '
Original file line number Diff line number Diff line change @@ -821,6 +821,7 @@ async function setup(testName: string): Promise<void> {
821821 sshKey : sshPath ? 'some ssh private key' : '' ,
822822 sshKnownHosts : '' ,
823823 sshStrict : true ,
824+ sshUser : '' ,
824825 workflowOrganizationId : 123456 ,
825826 setSafeDirectory : true ,
826827 githubServerUrl : githubServerUrl
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ inputs:
4545 and `CheckHostIP=no` to the SSH command line. Use the input `ssh-known-hosts` to
4646 configure additional hosts.
4747 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
4852 persist-credentials :
4953 description : ' Whether to configure the token or SSH key with the local git config'
5054 default : true
Original file line number Diff line number Diff line change @@ -1798,6 +1798,7 @@ function getInputs() {
17981798 result.sshKnownHosts = core.getInput('ssh-known-hosts');
17991799 result.sshStrict =
18001800 (core.getInput('ssh-strict') || 'true').toUpperCase() === 'TRUE';
1801+ result.sshUser = core.getInput('ssh-user');
18011802 // Persist credentials
18021803 result.persistCredentials =
18031804 (core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE';
@@ -2400,7 +2401,8 @@ function getFetchUrl(settings) {
24002401 const encodedOwner = encodeURIComponent(settings.repositoryOwner);
24012402 const encodedName = encodeURIComponent(settings.repositoryName);
24022403 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`;
24042406 }
24052407 // "origin" is SCHEME://HOSTNAME[:PORT]
24062408 return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`;
Original file line number Diff line number Diff line change @@ -94,6 +94,11 @@ export interface IGitSourceSettings {
9494 */
9595 sshStrict : boolean
9696
97+ /**
98+ * The SSH user to login as
99+ */
100+ sshUser : string
101+
97102 /**
98103 * Indicates whether to persist the credentials on disk to enable scripting authenticated git commands
99104 */
Original file line number Diff line number Diff line change @@ -143,6 +143,7 @@ export async function getInputs(): Promise<IGitSourceSettings> {
143143 result . sshKnownHosts = core . getInput ( 'ssh-known-hosts' )
144144 result . sshStrict =
145145 ( core . getInput ( 'ssh-strict' ) || 'true' ) . toUpperCase ( ) === 'TRUE'
146+ result . sshUser = core . getInput ( 'ssh-user' )
146147
147148 // Persist credentials
148149 result . persistCredentials =
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
1212 const encodedOwner = encodeURIComponent ( settings . repositoryOwner )
1313 const encodedName = encodeURIComponent ( settings . repositoryName )
1414 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`
1617 }
1718
1819 // "origin" is SCHEME://HOSTNAME[:PORT]
You can’t perform that action at this time.
0 commit comments