uppy/bin/web-deploy
Kevin van Zonneveld 73f89f08d9 Speed up website deploys
By re-using local git repo for gh-pages, making it only sync changes to GitHub

Time for actual deploy going down from `1m19.204s` to `0m5.640s` in local test

/cc @arturi
2019-03-28 10:50:01 +01:00

46 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
set -o pipefail
set -o errexit
set -o nounset
# set -o xtrace
# Set magic variables for current file & dir
# __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# __file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
# __base="$(basename ${__file} .sh)"
ghpages_repo=${GHPAGES_REPO:-"transloadit/uppy"}
ghpages_branch=${GHPAGES_BRANCH:-"gh-pages"}
ghpages_url=${GHPAGES_URL:-"git@github.com:${ghpages_repo}.git"}
localDir="${HOME:-/home/${USER:-travis}}/.${ghpages_repo}/deploy"
echo "--> Deploying to GitHub pages from '${localDir}'.."
mkdir -p "${localDir}"
# Custom steps
rsync \
--archive \
--delete \
--exclude=.git* \
--exclude=node_modules \
--exclude=lib \
--checksum \
--no-times \
--no-group \
--no-motd \
--no-owner \
./website/public/ "${localDir}" > /dev/null
echo 'This branch is just a deploy target. Do not edit. You changes will be lost.' \
|tee "${localDir}/README.md" > /dev/null
(cd "${localDir}" \
&& ([ -d .git ] || git init) && git checkout -B "${ghpages_branch}" && (git pull origin "${ghpages_branch}" || true) && git add --all . \
&& git commit --allow-empty --no-verify --message="Update ${ghpages_repo} website by ${USER}" \
&& (git remote add origin "${ghpages_url}"|| true) \
&& (git remote set-url origin "${ghpages_url}" || true) \
&& (git push origin "${ghpages_branch}:refs/heads/${ghpages_branch}" || git push origin "${ghpages_branch}:refs/heads/${ghpages_branch}" --force) \
) > /dev/null
# rm -rf "${localDir}"