Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2): docusaurus deploy: ability to configure port in git url #4545

Merged
merged 7 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/docusaurus-types/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface DocusaurusConfig {
organizationName?: string;
projectName?: string;
githubHost?: string;
githubPort?: string;
plugins?: PluginConfig[];
themes?: PluginConfig[];
presets?: PresetConfig[];
Expand Down
11 changes: 8 additions & 3 deletions packages/docusaurus/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,23 @@ export default async function deploy(
(projectName.indexOf('.github.io') !== -1 ? 'master' : 'gh-pages');
console.log(`${chalk.cyan('deploymentBranch:')} ${deploymentBranch}`);

const useSSH = process.env.USE_SSH;

const githubHost =
process.env.GITHUB_HOST || siteConfig.githubHost || 'github.com';
const githubPort = process.env.GITHUB_PORT || siteConfig.githubPort;

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 githubAddress = `${githubHost}${githubPort ? ':' + githubPort : ''}`;
const githubPath = `${organizationName}/${projectName}`;

const sshRemoteBranch: string = `ssh://git@${githubAddress}/${githubPath}.git`;
talesporto marked this conversation as resolved.
Show resolved Hide resolved
const nonSshRemoteBranch: string = `https://${gitCredentials}@${githubAddress}/${githubPath}.git`;

const remoteBranch =
useSSH && useSSH.toLowerCase() === 'true'
Expand Down
12 changes: 12 additions & 0 deletions website/docs/api/docusaurus.config.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,18 @@ module.exports = {
};
```

### `githubPort` {#githubPort}

- Type: `string`

The port of your server. Useful if you are using GitHub Enterprise.

```js title="docusaurus.config.js"
module.exports = {
githubPort: '22',
};
```

### `themeConfig` {#themeconfig}

- Type: `Object`
Expand Down
1 change: 1 addition & 0 deletions website/docs/deployment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ GitHub enterprise installations should work in the same manner as github.com; yo
| Name | Description |
| ------------- | ----------------------------------------------- |
| `GITHUB_HOST` | The domain name of your GitHub enterprise site. |
| `GITHUB_PORT` | The port of your GitHub enterprise site. |
talesporto marked this conversation as resolved.
Show resolved Hide resolved

### Deploy {#deploy}

Expand Down