feat(v2): Added the ability to specify GIT_PASS in deploy command (for CI purposes) (#3694)

* Added the ability to specify GIT_PASS (for CI purposes)

* Fixed variable copy issue

* Added documentation for GIT_PASS

Co-authored-by: Stephen McElhinney <stephen@appstruct.io>
This commit is contained in:
Stephen McElhinney 2020-11-09 12:13:10 +00:00 committed by GitHub
parent c895136665
commit 9309594da9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -72,10 +72,17 @@ export default async function deploy(
process.env.GITHUB_HOST || siteConfig.githubHost || 'github.com';
const useSSH = process.env.USE_SSH;
const gitPass: string | undefined = process.env.GIT_PASS;
let gitCredentials = `${gitUser}`;
if (gitPass) {
gitCredentials = `${gitCredentials}:${gitPass}`;
}
const sshRemoteBranch: string = `git@${githubHost}:${organizationName}/${projectName}.git`;
const nonSshRemoteBranch: string = `https://${gitCredentials}@${githubHost}/${organizationName}/${projectName}.git`;
const remoteBranch =
useSSH && useSSH.toLowerCase() === 'true'
? `git@${githubHost}:${organizationName}/${projectName}.git`
: `https://${gitUser}@${githubHost}/${organizationName}/${projectName}.git`;
useSSH && useSSH.toLowerCase() === 'true' ? sshRemoteBranch : nonSshRemoteBranch;
// Check if this is a cross-repo publish.
const currentRepoUrl = shell

View file

@ -88,6 +88,7 @@ Optional parameters, also set as environment variables:
| `USE_SSH` | Set to `true` to use SSH instead of the default HTTPS for the connection to the GitHub repo. |
| `DEPLOYMENT_BRANCH` | The branch that the website will be deployed to, defaults to `gh-pages` for normal repos and `master` for repository names ending in `github.io`. |
| `CURRENT_BRANCH` | The branch that contains the latest docs changes that will be deployed. Usually, the branch will be `master`, but it could be any branch (default or otherwise) except for `gh-pages`. If nothing is set for this variable, then the current branch will be used. |
| `GIT_PASS` | Password (or token) of the `git` user (specified by `GIT_USER`). For example, to facilitate non-interactive deployment (e.g. continuous deployment) |
### Deploy