-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdeploy.sh
executable file
·41 lines (32 loc) · 1.11 KB
/
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
#!/bin/bash
set -e
GHA_BRANCH=${GITHUB_REF#refs/heads/}
# Deploy built docs to this branch
TARGET_BRANCH=gh-pages
if [ ! -d "$SOURCE_DIR" ]; then
echo "SOURCE_DIR ($SOURCE_DIR) does not exist, build the source directory before deploying"
exit 1
fi
REPO=$(git config remote.origin.url)
echo DEPLOY_BRANCH: $DEPLOY_BRANCH
echo GIT_NAME: $GIT_NAME
echo GIT_EMAIL: $GIT_EMAIL
echo GHA_BRANCH: $GHA_BRANCH
if [ "$GHA_BRANCH" != "$DEPLOY_BRANCH" ]; then
echo "Actions should only deploy from the DEPLOY_BRANCH ($DEPLOY_BRANCH) branch"
exit 0
fi
REPO="https://RobinThrift:${GH_TOKEN}@github.com/HannoverJS/website.git"
git config --global user.name "$GIT_NAME"
git config --global user.email "$GIT_EMAIL"
REPO_NAME=$(basename $REPO)
TARGET_DIR=$(mktemp -d /tmp/$REPO_NAME.XXXX)
REV=$(git rev-parse HEAD)
git clone --branch ${TARGET_BRANCH} ${REPO} ${TARGET_DIR}
rsync -rt --delete --exclude=".git" --exclude=".github" $SOURCE_DIR/ $TARGET_DIR/
cd $TARGET_DIR
echo "hannoverjs.de" > CNAME
git add -A .
git commit --allow-empty -m "auto-build: build from $REV at $(date)"
git remote add gh $REPO
git push gh $TARGET_BRANCH