diff --git a/.gitignore b/.gitignore index 0e8c775..5427384 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ app/node_modules app/bundle.js node_modules +out +dist diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..3720ca4 --- /dev/null +++ b/.travis.yml @@ -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= diff --git a/utils/deploy.js b/utils/deploy.js new file mode 100755 index 0000000..28955a4 --- /dev/null +++ b/utils/deploy.js @@ -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);