github-setup.sh 849 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. ##
  3. # Prepares a GitHub repo for deployment
  4. #
  5. # @author Daniel Rudolf
  6. # @link http://picocms.org
  7. # @license http://opensource.org/licenses/MIT
  8. #
  9. set -e
  10. # environment variables
  11. # GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens
  12. # print "parameters" (we don't have any)
  13. echo "Setup repo..."
  14. echo
  15. # check for git repo
  16. if ! git rev-parse --git-dir > /dev/null 2>&1; then
  17. echo "Not a git repo; aborting..." >&2
  18. exit 1
  19. fi
  20. # setup git
  21. printf 'Preparing repo...\n'
  22. git config push.default simple
  23. git config user.name "Travis CI"
  24. git config user.email "travis-ci@picocms.org"
  25. if [ -n "$GITHUB_OAUTH_TOKEN" ]; then
  26. git config credential.helper 'store --file=.git/credentials'
  27. (umask 077 && echo "https://GitHub:$GITHUB_OAUTH_TOKEN@github.com" > .git/credentials)
  28. fi
  29. echo