forked from spacetelescope/notebooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gh_pages_deploy.sh
executable file
·48 lines (42 loc) · 1.15 KB
/
gh_pages_deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# vars for this script:
# REPO_URL - repo url to clone from (https or ssh)
# DEPLOY_BRANCH - branch to deploy to (normally gh-pages)
# WORKSPACE - where to copy files from to add to deploy commit (build location)
# BUILD_TAG - tag for deploy commit
# REMOTE_NAME - remote to push up to
# These can be set by using "export var=value" for manual deploy
# Or they are set in environment vars when used on CI
# set some defaults for the environment variables
if [[ -z "${REPO_URL}" ]]; then
REPO_URL="."
else
REPO_URL="${REPO_URL}"
fi
if [[ -z "${DEPLOY_BRANCH}" ]]; then
DEPLOY_BRANCH="gh-pages"
else
DEPLOY_BRANCH="${DEPLOY_BRANCH}"
fi
if [[ -z "${WORKSPACE}" ]]; then
WORKSPACE="$PWD"
else
WORKSPACE="${WORKSPACE}"
fi
if [[ -z "${BUILD_TAG}" ]]; then
BUILD_TAG="manual build"
else
BUILD_TAG="${BUILD_TAG}"
fi
if [[ -z "${REMOTE_NAME}" ]]; then
REMOTE_NAME="origin"
else
REMOTE_NAME="${REMOTE_NAME}"
fi
git clone -b ${DEPLOY_BRANCH} --single-branch ${REPO_URL} /out
cd /out
cp -aR ${WORKSPACE}/* .
git add .
git commit -m "Automated deployment to GitHub Pages: ${BUILD_TAG}" --allow-empty
git push $REMOTE_NAME $DEPLOY_BRANCH
git clean -dfx