Skip to content

Commit 3a5e172

Browse files
committed
Add a Makefile for deploying to gh-pages
1 parent 1df0dbd commit 3a5e172

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public/

Makefile

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# type `make help` to see all options
2+
3+
# To build and test the website locally, simply do:
4+
# $ hugo
5+
# $ hugo server
6+
7+
TARGET ?= upstream
8+
BASEURL ?=
9+
10+
WORKTREETARGET = "$(TARGET)/gh-pages"
11+
12+
ifdef BASEURL
13+
BASEURLARG=-b $(BASEURL)
14+
endif
15+
16+
all: build
17+
18+
.PHONY: serve html clean deploy help
19+
20+
.SILENT: # remove this to see the commands executed
21+
22+
public: ## create a worktree branch in the public directory
23+
git worktree add -B gh-pages public $(WORKTREETARGET)
24+
rm -rf public/*
25+
26+
html: public ## build the website in ./public
27+
hugo $(BASEURLARG)
28+
touch public/.nojekyll
29+
echo data-apis.org > public/CNAME
30+
31+
public/.nojekyll: html
32+
33+
clean: ## remove the build artifacts, mainly the "public" directory
34+
rm -rf public
35+
git worktree prune
36+
rm -rf .git/worktrees/public
37+
38+
deploy: public/.nojekyll ## push the built site to the gh-pages of this repo
39+
cd public && git add --all && git commit -m"Publishing to gh-pages"
40+
@echo pushint to $(TARGET) gh-pages
41+
git push $(TARGET) gh-pages
42+
43+
44+
# Add help text after each target name starting with '\#\#'
45+
help: ## Show this help.
46+
@echo "\nHelp for this makefile"
47+
@echo "Possible commands are:"
48+
@grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/\(.*\):.*##\(.*\)/ \1: \2/'

0 commit comments

Comments
 (0)