web-deploy 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. ghpages_repo=${GHPAGES_REPO:-"transloadit/uppy"}
  11. ghpages_branch=${GHPAGES_BRANCH:-"gh-pages"}
  12. ghpages_url=${GHPAGES_URL:-"git@github.com:${ghpages_repo}.git"}
  13. echo "--> Deploying to GitHub pages.."
  14. mkdir -p /tmp/deploy-${ghpages_repo}
  15. # Custom steps
  16. rsync \
  17. --archive \
  18. --delete \
  19. --exclude=.git* \
  20. --exclude=node_modules \
  21. --exclude=lib \
  22. --checksum \
  23. --no-times \
  24. --no-group \
  25. --no-motd \
  26. --no-owner \
  27. ./website/public/ /tmp/deploy-${ghpages_repo} > /dev/null
  28. echo 'This branch is just a deploy target. Do not edit. You changes will be lost.' \
  29. |tee /tmp/deploy-${ghpages_repo}/README.md
  30. (cd /tmp/deploy-${ghpages_repo} \
  31. && git init && git checkout -B ${ghpages_branch} && git add --all . \
  32. && git commit -nm "Update ${ghpages_repo} website by ${USER}" \
  33. && (git remote add origin ${ghpages_url}|| true) \
  34. && git push origin ${ghpages_branch}:refs/heads/${ghpages_branch} --force) > /dev/null
  35. rm -rf /tmp/deploy-${ghpages_repo}