Guard against errors during the deploy step, and install rsync (#277)

This commit is contained in:
Héctor Ramos 2017-12-12 10:16:26 -08:00 committed by Joel Marcey
parent ea5a11bcd0
commit cf89dacaf6
2 changed files with 21 additions and 8 deletions

View file

@ -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: |

View file

@ -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);