publish-do.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #! /bin/bash
  2. # Push my blog to "production" server
  3. #
  4. # Usage: [DRY_RUN=1] publish-do.sh ["Comment about article/commit"]
  5. # This is bash. Be safe out there.
  6. set -e
  7. set -u
  8. COMMENT="${1:-No comment}"
  9. source ~/lib/bash/bashutils.sh # for error functions
  10. # be sure we're in the right place
  11. cd ~/blog
  12. # make sure blog source exists
  13. test -f curious.org || die "Blog ox-hugo source curious.org does not exist"
  14. # create the new docs/ directory/files
  15. info Running hugo
  16. test -v DRY_RUN || hugo
  17. info Pushing to web
  18. test -v DRY_RUN || rsync -avz --delete docs/ curious:/var/www/curious.galthub.com/
  19. info Adding things to git
  20. if [[ "$COMMENT" == "No comment" ]]; then
  21. read -r -p "Enter a comment about this change/article: " COMMENT
  22. else
  23. debug COMMENT "$COMMENT"
  24. fi
  25. test -v DRY_RUN && PRINT=info || PRINT=
  26. $PRINT rsync -avz --delete docs/ curious:/var/www/curious.galthub.com/
  27. $PRINT git add curious.org
  28. $PRINT git add images
  29. $PRINT git add content
  30. $PRINT git commit -m"Published $(date): ${COMMENT}"
  31. info "done"