mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 22:17:00 +02:00
Support publishing to Github Enterprise hosting (#689)
* Added support for Github Enterprise GH Pages * Fixed with prettier output * Tweak * Tweak * Tweak
This commit is contained in:
parent
93b2ebb53b
commit
2bd9a148c1
3 changed files with 24 additions and 6 deletions
|
@ -62,7 +62,7 @@ headerLinks: [
|
|||
|
||||
`title` - Title for your website.
|
||||
|
||||
`url` - url for your site.
|
||||
`url` - URL for your website.
|
||||
|
||||
### Optional Fields
|
||||
|
||||
|
@ -131,6 +131,8 @@ h1 {
|
|||
|
||||
`gaGtag` - Set this to `true` if you want to use [global site tags (gtag.js)](https://developers.google.com/gtagjs/) for Google analytics instead of `analytics.js`.
|
||||
|
||||
`githubHost` - Hostname of your server. Useful if you are using GitHub Enterprise.
|
||||
|
||||
`highlight` - [Syntax highlighting](api-doc-markdown.md) options:
|
||||
|
||||
* `theme` is the name of the theme used by Highlight.js when highlighting code. You can find the [list of supported themes here](https://github.com/isagalaev/highlight.js/tree/master/src/styles).
|
||||
|
|
|
@ -204,3 +204,13 @@ Steps to configure your Docusaurus-powered site on Netlify.
|
|||
1. Click **Deploy site**
|
||||
|
||||
You can also configure Netlify to rebuild on every commit to your repo, or only `master` branch commits.
|
||||
|
||||
### Publishing to GitHub Enterprise
|
||||
|
||||
GitHub enterprise installations should work in the same manner as github.com; you only need to identify the organization's GitHub Enterprise host.
|
||||
|
||||
| Name | Description |
|
||||
| ------------- | ----------------------------------------------- |
|
||||
| `GITHUB_HOST` | The hostname for the GitHub enterprise server. |
|
||||
|
||||
Alter your `siteConfig.js` to add a property `'githubHost'` which represents the GitHub Enterprise hostname. Alternatively, set an environment variable `GITHUB_HOST` when executing the publish command.
|
||||
|
|
|
@ -35,6 +35,10 @@ const USE_SSH = process.env.USE_SSH;
|
|||
// github.io indicates organization repos that deploy via master. All others use gh-pages.
|
||||
const DEPLOYMENT_BRANCH =
|
||||
PROJECT_NAME.indexOf('.github.io') !== -1 ? 'master' : 'gh-pages';
|
||||
const GITHUB_DOMAIN = 'github.com';
|
||||
// For GitHub enterprise, allow specifying a different host.
|
||||
const GITHUB_HOST =
|
||||
process.env.GITHUB_HOST || siteConfig.githubHost || GITHUB_DOMAIN;
|
||||
|
||||
if (!ORGANIZATION_NAME) {
|
||||
shell.echo(
|
||||
|
@ -52,9 +56,9 @@ if (!PROJECT_NAME) {
|
|||
|
||||
let remoteBranch;
|
||||
if (USE_SSH === 'true') {
|
||||
remoteBranch = `git@github.com:${ORGANIZATION_NAME}/${PROJECT_NAME}.git`;
|
||||
remoteBranch = `git@${GITHUB_HOST}:${ORGANIZATION_NAME}/${PROJECT_NAME}.git`;
|
||||
} else {
|
||||
remoteBranch = `https://${GIT_USER}@github.com/${ORGANIZATION_NAME}/${PROJECT_NAME}.git`;
|
||||
remoteBranch = `https://${GIT_USER}@${GITHUB_HOST}/${ORGANIZATION_NAME}/${PROJECT_NAME}.git`;
|
||||
}
|
||||
|
||||
if (IS_PULL_REQUEST) {
|
||||
|
@ -150,9 +154,11 @@ fs.copy(
|
|||
shell.exit(1);
|
||||
} else if (commitResults.code === 0) {
|
||||
// The commit might return a non-zero value when site is up to date.
|
||||
shell.echo(
|
||||
`Website is live at: https://${ORGANIZATION_NAME}.github.io/${PROJECT_NAME}`
|
||||
);
|
||||
const websiteURL =
|
||||
GITHUB_HOST === GITHUB_DOMAIN
|
||||
? `https://${ORGANIZATION_NAME}.github.io/${PROJECT_NAME}` // gh-pages hosted repo
|
||||
: `https://${GITHUB_HOST}/pages/${ORGANIZATION_NAME}/${PROJECT_NAME}`; // GitHub enterprise hosting.
|
||||
shell.echo(`Website is live at: ${websiteURL}`);
|
||||
shell.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue