Skip to content

Commit

Permalink
Only deploy on master. Skip PRs.
Browse files Browse the repository at this point in the history
  • Loading branch information
hramos committed Feb 2, 2017
1 parent 9fd386f commit e33c169
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion website/publish-gh-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@
require(`shelljs/global`);

const GIT_USER = process.env.GIT_USER;
const CIRCLE_BRANCH = process.env.CIRCLE_BRANCH;
const CIRCLE_PROJECT_USERNAME = process.env.CIRCLE_PROJECT_USERNAME;
const CIRCLE_PROJECT_REPONAME = process.env.CIRCLE_PROJECT_REPONAME;
const CI_PULL_REQUEST = process.env.CI_PULL_REQUEST;
const remoteBranch = `https://${GIT_USER}@github.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}.git`;

if (!which(`git`)) {
echo(`Sorry, this script requires git`);
exit(1);
}

if (CI_PULL_REQUEST || CIRCLE_BRANCH !== `master` || CIRCLE_PROJECT_USERNAME !== `facebook`) {
echo(`Skipping deploy`);
exit(0);
}

echo(`Building branch ${CIRCLE_BRANCH}, preparing to push to gh-pages`);

// Clear out existing build folder
rm(`-rf`, `build`);
mkdir(`-p`, `build`);
Expand All @@ -39,7 +48,7 @@ if (exec(`git checkout origin/gh-pages`).code +
cd(`../..`);

if (exec(`node server/generate.js`).code) {
echo(`Error: generate failed`);
echo(`Error: Generating HTML failed`);
exit(1);
}

Expand Down

0 comments on commit e33c169

Please sign in to comment.