-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
33 lines (27 loc) · 695 Bytes
/
Copy pathMakefile
File metadata and controls
33 lines (27 loc) · 695 Bytes
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
PHONY: run deploy
build: src/*
-rm -r build/
cp -R src/ build/
run: build
cd build && python -m http.server
TARGET_BRANCH=gh-pages
REPO = $(shell git config remote.origin.url)
SSH_REPO = $(REPO:https://github.com/%=git@github.com:%)
SHA = $(shell git rev-parse --verify HEAD)
.ONESHELL:
deploy: build
if [ ! -e "out" ]; then
git clone $(REPO) out
cd out
git checkout $(TARGET_BRANCH) || git checkout --orphan $(TARGET_BRANCH)
else
cd out
git checkout $(TARGET_BRANCH)
git pull --rebase origin $(TARGET_BRANCH)
fi
rm -rf **/* || exit 0
cp -R ../build/* .
rm -rf **/.git
git add .
git commit -m "Deploy to GitHub Pages: ${SHA}"
git push $(SSH_REPO) $(TARGET_BRANCH)