Skip to content

Commit

Permalink
add auto deploy from Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
chialin committed Jul 17, 2015
1 parent daf634f commit 0e8b846
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
app/node_modules
app/bundle.js
node_modules
out
dist
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js: '0.12'
branches:
only:
- master
script: node utils/deploy.js
env:
global:
- GH_REF: github.com/chialin/hackeditr.git
# GH_TOKEN
- secure: BSYbxTtdxRWllrI7b4oc4qUAqgSkydSwx6t6yV9/90JR8AjnV7eMR5X9124PSkUOnnfd0AapaOzmuuTOeimnP6uZHMejbOO7Gfnja6V8kM+/niFh/R2uHzPzR9BnBHRdZpro7+2HTOPY7Gw4EsBcVN/Tw0lsHa8O2UEK5vSiRY/CBq8QVr/2KvFneTHqqWV5a5VMGUVfzMyZFMcmWi/LgkbyeKlEo7qcuc1t56E1tx9kBo/xjtBTbJnGPoB4mAOqw5JafjjJ1qySPe4xwIumpmomsXHwdblXI7bw+mcbHH6rwou6emaGFE8AvmTLMEnGMH5GGgPKpcA/dOIXfB8rN3mtJo7wqSQJX2vy++SLXZoNExcvB3yu8KCPoPWLYxsM9Uu4rGc8oRTlHHom1Q+WP4rd9rwyiCKdeGkwuVTwQ0ayM5tYYtdchugNw9FNgoEykmjlhcxv/+nI+vQxChHiu4anj/lHGcG9Gry2GBf0bXLwzQYxqqS1NSPMOBKaVUeybI8yf51zjCLQCT+Lf8DbcagAsGpkctFO5OqBJ1fMSeSwSvKOMcF3SySFoPa1x9lfpjMQtCUpAhqSAvPWJX43iMxeLW2KiIZ4rRrVsiWw0t3qeqIyvzVMPdn5HqTKyJVhDdDT+y/ngN7Mt1kf59ynpgr8nkQk9kyKBadOJGKekYE=
33 changes: 33 additions & 0 deletions utils/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env node

require('shelljs/global');
require('shelljs/make');

mkdir('-p', 'dist');
mkdir('-p', 'dist/node_modules/bootstrap/dist/fonts');

exec('npm run build', function(code, output) {
if (code !== 0) {
console.log('fail');
} else {
if(test('-f', 'app/bundle.js')) {
cp('-f', 'app/bundle.js', 'dist/bundle.js');
}
}
});

cp('-f', 'app/index.html', 'dist/index.html');
cp('-f', 'app/dialog.html', 'dist/dialog.html');
cp('-Rf', 'node_modules/bootstrap/dist/fonts/*', 'dist/node_modules/bootstrap/dist/fonts');

rm('-rf', 'out');
exec('git clone "https://' + env.GH_TOKEN + '@' + env.GH_REF + '" --depth 1 -b gh-pages out');
cd('out');
exec('git config user.name "Travis CI"');
exec('git config user.email "chialin.shr@gmail.com"');
cp('-Rf', '../dist/*', '.');
exec('git add .');
exec('git commit --allow-empty -m "Automatic commit: ' + Date() + '"');
exec('git push "https://' + env.GH_TOKEN + '@' + env.GH_REF + '" gh-pages', {silent:true});

exit(0);

0 comments on commit 0e8b846

Please sign in to comment.