web-deploy 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. set -o pipefail
  3. set -o errexit
  4. set -o nounset
  5. # set -o xtrace
  6. # Set magic variables for current file & dir
  7. __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  8. __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
  9. __base="$(basename ${__file} .sh)"
  10. git config user.name 'Uppy Bot'
  11. git config user.email 'uppybot@uppy.io'
  12. ghpages_repo=${GHPAGES_REPO:-"transloadit/uppy"}
  13. ghpages_branch=${GHPAGES_BRANCH:-"gh-pages"}
  14. ghpages_url=${GHPAGES_URL:-"git@github.com:${ghpages_repo}.git"}
  15. echo "--> Deploying to GitHub pages.."
  16. mkdir -p /tmp/deploy-${ghpages_repo}
  17. # Custom steps
  18. rsync \
  19. --archive \
  20. --delete \
  21. --exclude=.git* \
  22. --exclude=node_modules \
  23. --exclude=lib \
  24. --checksum \
  25. --no-times \
  26. --no-group \
  27. --no-motd \
  28. --no-owner \
  29. ./website/public/ /tmp/deploy-${ghpages_repo} > /dev/null
  30. echo 'This branch is just a deploy target. Do not edit. You changes will be lost.' \
  31. |tee /tmp/deploy-${ghpages_repo}/README.md
  32. (cd /tmp/deploy-${ghpages_repo} \
  33. && git init && git checkout -B ${ghpages_branch} && git add --all . \
  34. && git commit -nm "Update ${ghpages_repo} website by ${USER}" \
  35. && (git remote add origin ${ghpages_url}|| true) \
  36. && git push origin ${ghpages_branch}:refs/heads/${ghpages_branch} --force) > /dev/null
  37. rm -rf /tmp/deploy-${ghpages_repo}