mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
Switch to rsync package (#320)
* Switch to rsync package This removes the need to install rsync natively in CI * Update publish-gh-pages.js
This commit is contained in:
parent
ddf9827ae6
commit
60bd8bc754
|
|
@ -66,9 +66,6 @@ jobs:
|
|||
git config --global user.name "Website Deployment Script"
|
||||
echo "machine github.com login facebook-github-bot" > ~/.netrc
|
||||
fi
|
||||
- run:
|
||||
name: Install Dependencies
|
||||
command: sudo apt install rsync
|
||||
- run:
|
||||
name: Deploy Website
|
||||
command: |
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const shell = require('shelljs');
|
||||
const path = require('path');
|
||||
const Rsync = require('rsync');
|
||||
const shell = require('shelljs');
|
||||
|
||||
if (!shell.which('git')) {
|
||||
shell.echo('Sorry, this script requires git');
|
||||
|
|
@ -116,30 +117,36 @@ excludePath = `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`;
|
|||
// cannot use shell.cp because it doesn't support copying dotfiles and we
|
||||
// need to copy directories like .circleci, for example
|
||||
// https://github.com/shelljs/shelljs/issues/79
|
||||
if (
|
||||
shell.exec(
|
||||
`rsync -rt --exclude=${excludePath} --exclude=.DS_Store ${fromPath} ${toPath}`
|
||||
).code !== 0
|
||||
) {
|
||||
shell.echo(`Error: Copying build assets failed`);
|
||||
shell.exit(1);
|
||||
}
|
||||
const rsync = new Rsync()
|
||||
.flags('rt')
|
||||
.exclude(excludePath)
|
||||
.exclude('.DS_Store')
|
||||
.source(fromPath)
|
||||
.destination(toPath);
|
||||
|
||||
shell.cd(path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`));
|
||||
rsync.execute((error, code, cmd) => {
|
||||
if (code !== 0) {
|
||||
shell.echo(`Error: Copying build assets failed`);
|
||||
shell.exit(1);
|
||||
} else {
|
||||
shell.cd(path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`));
|
||||
|
||||
const currentCommit = shell.exec('git rev-parse HEAD').stdout.trim();
|
||||
const currentCommit = shell.exec('git rev-parse HEAD').stdout.trim();
|
||||
|
||||
shell.exec('git add --all');
|
||||
shell.exec('git add --all');
|
||||
|
||||
shell.exec(
|
||||
`git commit -m "Deploy website" -m "Deploy website version based on ${currentCommit}"`
|
||||
);
|
||||
if (shell.exec(`git push origin ${DEPLOYMENT_BRANCH}`).code !== 0) {
|
||||
shell.echo('Error: Git push failed');
|
||||
shell.exit(1);
|
||||
} else {
|
||||
shell.echo(
|
||||
`Website is live at: https://${ORGANIZATION_NAME}.github.io/${PROJECT_PATH}`
|
||||
);
|
||||
shell.exit(0);
|
||||
}
|
||||
const commitResults = shell.exec(
|
||||
`git commit -m "Deploy website" -m "Deploy website version based on ${currentCommit}"`
|
||||
);
|
||||
if (shell.exec(`git push origin ${DEPLOYMENT_BRANCH}`).code !== 0) {
|
||||
shell.echo('Error: Git push failed');
|
||||
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_PATH}`
|
||||
);
|
||||
shell.exit(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
"react-dom-factories": "^1.0.1",
|
||||
"remarkable": "^1.7.1",
|
||||
"request": "^2.81.0",
|
||||
"rsync": "^0.6.1",
|
||||
"shelljs": "^0.7.8",
|
||||
"sitemap": "^1.13.0",
|
||||
"tcp-port-used": "^0.1.2"
|
||||
|
|
@ -60,11 +61,11 @@
|
|||
"docusaurus-feed": "./lib/generate-feed.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prettier": "^1.9.1",
|
||||
"filepath": "^1.1.0",
|
||||
"front-matter": "^2.3.0",
|
||||
"glob-promise": "^3.3.0",
|
||||
"jest": "^21.2.1",
|
||||
"prettier": "^1.9.1",
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2953,6 +2953,10 @@ rimraf@2, rimraf@^2.5.1, rimraf@^2.6.1, rimraf@^2.6.2:
|
|||
dependencies:
|
||||
glob "^7.0.5"
|
||||
|
||||
rsync@^0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/rsync/-/rsync-0.6.1.tgz#3681a0098bd8750448f8bf9da1fee09f7763742b"
|
||||
|
||||
safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
|
||||
|
|
|
|||
Loading…
Reference in New Issue