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