-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·28 lines (23 loc) · 1.14 KB
/
deploy.sh
File metadata and controls
executable file
·28 lines (23 loc) · 1.14 KB
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
#!/bin/bash
TWENTYFOUR_SRC_DIR=${HOME}/code/twentyfour
GITHUB_PAGES_SRC_DIR=${HOME}/code/24game.github.io
if [ ! -d "$TWENTYFOUR_SRC_DIR" ]; then
# Directory doesn't exist
[[ `id -u` -eq 0 ]] || { echo "Expected twentyfour code directory at ${TWENTYFOUR_SRC_DIR} but it doesn't exist. Please adjust the path to your twentyfour source directory in this script."; exit 1; }
fi
if [ ! -d "$GITHUB_PAGES_SRC_DIR" ]; then
# Directory doesn't exist
[[ `id -u` -eq 0 ]] || { echo "Expected 24game.github.io code directory at ${GITHUB_PAGES_SRC_DIR} but it doesn't exist. Please adjust the path to your 24game.github.io source directory in this script."; exit 1; }
fi
echo "Copying ${TWENTYFOUR_SRC_DIR}/public to ${GITHUB_PAGES_SRC_DIR}..."
cp ${TWENTYFOUR_SRC_DIR}/* ${GITHUB_PAGES_SRC_DIR}
# Get last commit info
cd ${TWENTYFOUR_SRC_DIR}
COMMIT_HASH=$(git rev-parse --short HEAD)
COMMIT_MESSAGE=$(git log -1 --pretty=format:%s)
# Deploy to GitHub pages to trigger a page rebuild
cd ${GITHUB_PAGES_SRC_DIR}
git add .
git commit -m "[Deploy] ${COMMIT_HASH}: ${COMMIT_MESSAGE}"
echo "Deploying ${COMMIT_HASH} ${COMMIT_MESSAGE}..."
git push origin master --force