web-deploy 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. localDir="${HOME:-/home/${USER:-travis}}/.${ghpages_repo}/deploy"
  14. echo "--> Deploying to GitHub pages from '${localDir}'.."
  15. mkdir -p "${localDir}"
  16. # Custom steps
  17. rsync \
  18. --archive \
  19. --delete \
  20. --exclude=.git* \
  21. --exclude=node_modules \
  22. --exclude=lib \
  23. --checksum \
  24. --no-times \
  25. --no-group \
  26. --no-motd \
  27. --no-owner \
  28. ./website/public/ "${localDir}" > /dev/null
  29. echo 'This branch is just a deploy target. Do not edit. You changes will be lost.' \
  30. |tee "${localDir}/README.md" > /dev/null
  31. (cd "${localDir}" \
  32. && ([ -d .git ] || git init) && git checkout -B "${ghpages_branch}" && (git pull origin "${ghpages_branch}" || true) && git add --all . \
  33. && git commit --allow-empty --no-verify --message="Update ${ghpages_repo} website by ${USER}" \
  34. && (git remote add origin "${ghpages_url}"|| true) \
  35. && (git remote set-url origin "${ghpages_url}" || true) \
  36. && (git push origin "${ghpages_branch}:refs/heads/${ghpages_branch}" || git push origin "${ghpages_branch}:refs/heads/${ghpages_branch}" --force) \
  37. ) > /dev/null
  38. # rm -rf "${localDir}"