From cf89dacaf65021b45d74eb0d40570e8b227041d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= <165856+hramos@users.noreply.github.com> Date: Tue, 12 Dec 2017 10:16:26 -0800 Subject: [PATCH] Guard against errors during the deploy step, and install rsync (#277) --- .circleci/config.yml | 3 +++ lib/publish-gh-pages.js | 26 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 30a2bc7e83..71473010a2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,6 +63,9 @@ 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: | diff --git a/lib/publish-gh-pages.js b/lib/publish-gh-pages.js index ebc6c36aa0..5bba6cf614 100755 --- a/lib/publish-gh-pages.js +++ b/lib/publish-gh-pages.js @@ -118,9 +118,14 @@ 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 -shell.exec( - `rsync -rt --exclude=${excludePath} --exclude=.DS_Store ${fromPath} ${toPath}` -); +if ( + shell.exec( + `rsync -rt --exclude=${excludePath} --exclude=.DS_Store ${fromPath} ${toPath}` + ).code !== 0 +) { + shell.echo(`Error: Copying build assets failed`); + shell.exit(1); +} shell.cd(path.join('build', `${PROJECT_NAME}-${DEPLOYMENT_BRANCH}`)); @@ -128,11 +133,16 @@ const currentCommit = shell.exec('git rev-parse HEAD').stdout.trim(); shell.exec('git add --all'); -shell.exec( - `git commit -m "Deploy website" -m "Deploy website version based on ${ - currentCommit - }"` -); +if ( + shell.exec( + `git commit -m "Deploy website" -m "Deploy website version based on ${ + currentCommit + }"` + ).code !== 0 +) { + shell.echo(`Error: Committing static website failed`); + shell.exit(1); +} if (shell.exec(`git push origin ${DEPLOYMENT_BRANCH}`).code !== 0) { shell.echo('Error: Git push failed'); shell.exit(1);