cmd 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. pushd $(dirname "${0}") > /dev/null
  3. DIR=$(pwd -L)
  4. popd > /dev/null
  5. ACTION=$1
  6. build() {
  7. git add .
  8. git commit -m 'Gitbook Auto Published'
  9. git push origin master
  10. git push coding master
  11. node_modules/.bin/gitbook build
  12. cd $DIR/_book && git add .
  13. cd $DIR/_book && git commit -m "Gitbook Auto Deployed"
  14. cd $DIR/_book && git push -f coding master:coding-pages
  15. cd $DIR/_book && git push -f origin master:gh-pages
  16. }
  17. clean() {
  18. git add .
  19. git commit -m 'Gitbook Auto Published'
  20. git push origin master
  21. git push coding master
  22. rm -rf _book
  23. node_modules/.bin/gitbook build
  24. cd $DIR/_book && git init
  25. cd $DIR/_book && git add .
  26. cd $DIR/_book && git commit -m "Gitbook Auto Deployed"
  27. cd $DIR/_book && git remote add origin git@github.com:js-cool/leader.js.cool.git
  28. cd $DIR/_book && git remote add coding git@git.coding.net:willin/leader.js.cool.git
  29. cd $DIR/_book && git push -f coding master:coding-pages
  30. cd $DIR/_book && git push -f origin master:gh-pages
  31. }
  32. case "$ACTION" in
  33. clean)
  34. clean
  35. ;;
  36. *)
  37. build
  38. ;;
  39. esac