Skip to content

Commit

Permalink
Clean up gulpfile and travis config a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfly committed Jul 15, 2018
1 parent 987e659 commit 9879ddf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ cache:
before_install:
- sudo apt-get -qq update
- sudo apt-get install -y potrace
before_script:
- npm install -g gulp
script: gulp deployTravis
script: npm run deploy
env:
global:
# Set the GH_TOKEN environment variable needed by "gulp deploy-travis"
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ We use the excellent [gulp-iconfont](https://www.npmjs.com/package/gulp-iconfont

## Deploy to GitHub Pages

TravisCI automatically runs `gulp deployTravis`, but that's only for the main
repository. If you want to see your changes on your own fork,
you can run `gulp deploy`.
```
gulp deploy
```

This will deploy to the `gh-pages` branch of whatever remote your `origin` is
pointing at. TravisCI will automatically run this whenever code is pushed to
`master`.
18 changes: 7 additions & 11 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,12 @@ export const watch = gulp.series(defaultTask, function watching() {
gulp.watch(SRC_FILES, defaultTask);
});

export function deployHelper() {
return gulp.src('./www/**/*.*')
.pipe(ghPages());
}
export const deploy = gulp.series(clean, defaultTask, deployHelper);

// Inspired by https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
export function deployTravisHelper(done) {
if(process.env.TRAVIS_PULL_REQUEST !== "false") {
export const deploy = gulp.series(clean, defaultTask, function deploying(done) {
// Inspired by https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
if(process.env.TRAVIS !== "true") {
return gulp.src('./www/**/*.*')
.pipe(ghPages());
} else if(process.env.TRAVIS_PULL_REQUEST !== "false") {
console.log(`Building PR #${process.env.TRAVIS_PULL_REQUEST} on branch ${process.env.TRAVIS_BRANCH}, not deploying`);
done();
} else if(process.env.TRAVIS_BRANCH !== "master") {
Expand All @@ -97,8 +94,7 @@ export function deployTravisHelper(done) {
remoteUrl: `https://${process.env.GH_TOKEN}@github.com/cubing/icons.git`
}));
}
};
export const deployTravis = gulp.series(clean, defaultTask, deployTravisHelper);
});

export function clean() {
return del('www');
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "gulp",
"watch": "gulp watch"
"watch": "gulp watch",
"deploy": "gulp deploy"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 9879ddf

Please sign in to comment.