Unverified Commit 1d96c772 authored by Cory Miller's avatar Cory Miller Committed by GitHub
Browse files

Add SSH user parameter (#1685)

* Add a configurable SSH user

* Update docs with param

* Indentation of readme

* formatting woes

* Update src/url-helper.ts

Co-authored-by: default avatarJosh Gross <[email protected]>

* Update action.yml

Co-authored-by: default avatarJosh Gross <[email protected]>

* Update genfiles

---------

Co-authored-by: default avatarJosh Gross <[email protected]>
parent cd7d8d69
Loading
Loading
Loading
Loading
+5
Changes for README.md: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -62,6 +62,11 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
    # Default: true
    ssh-strict: ''

    # The user to use when connecting to the remote SSH host. By default 'git' is
    # used.
    # Default: git
    ssh-user: ''

    # Whether to configure the token or SSH key with the local git config
    # Default: true
    persist-credentials: ''
+1
Changes for __test__/git-auth-helper.test.ts: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -821,6 +821,7 @@ async function setup(testName: string): Promise<void> {
    sshKey: sshPath ? 'some ssh private key' : '',
    sshKnownHosts: '',
    sshStrict: true,
    sshUser: '',
    workflowOrganizationId: 123456,
    setSafeDirectory: true,
    githubServerUrl: githubServerUrl
+4
Changes for action.yml: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -45,6 +45,10 @@ inputs:
      and `CheckHostIP=no` to the SSH command line. Use the input `ssh-known-hosts` to
      configure additional hosts.
    default: true
  ssh-user:
    description: >
      The user to use when connecting to the remote SSH host. By default 'git' is used.
    default: git
  persist-credentials:
    description: 'Whether to configure the token or SSH key with the local git config'
    default: true
+3 −1
Changes for dist/index.js: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -1798,6 +1798,7 @@ function getInputs() {
        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 =
            (core.getInput('persist-credentials') || 'false').toUpperCase() === 'TRUE';
@@ -2400,7 +2401,8 @@ function getFetchUrl(settings) {
    const encodedOwner = encodeURIComponent(settings.repositoryOwner);
    const encodedName = encodeURIComponent(settings.repositoryName);
    if (settings.sshKey) {
        return `git@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`;
        const user = settings.sshUser.length > 0 ? settings.sshUser : 'git';
        return `${user}@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`;
    }
    // "origin" is SCHEME://HOSTNAME[:PORT]
    return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`;
+5
Changes for src/git-source-settings.ts: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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
   */
Loading