-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
70 lines (55 loc) · 1.71 KB
/
Makefile
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
TITLE ?= New Post
BASE_DIR = $(shell pwd)
SRC = $(BASE_DIR)/src
BUILD_DIR = $(BASE_DIR)/build
POSTS_DIR = $(SRC)/_posts
PUBLISH_DIR = $(BASE_DIR)/generated
GITHUB_PAGES = $(BASE_DIR)/docker/gh-pages/pages-gem
GUEST_BUILD_DIR = /blog/build
GUEST_POSTS_DIR = /blog/_posts
REPO = $(shell git config --get remote.origin.url)
.PHONY: build
default: build
$(GITHUB_PAGES):
@mkdir -p `basename $(GITHUB_PAGES)`
@git clone [email protected]:github/pages-gem.git $(GITHUB_PAGES)
@cd $(GITHUB_PAGES) && \
git checkout v24
$(GITHUB_PAGES)/.build: $(GITHUB_PAGES)
@cd docker/gh-pages && \
docker build . -t github-pages && \
touch $(GITHUB_PAGES)/.build
build: clean-build $(GITHUB_PAGES)/.build
@docker build . -t lfe/blog
@docker run \
--volume="$(BUILD_DIR):/$(GUEST_BUILD_DIR)" \
lfe/blog build --verbose --trace --destination $(GUEST_BUILD_DIR)
$(MAKE) update-generated
update-generated:
@cp -r $(BUILD_DIR)/* $(PUBLISH_DIR)/
build-and-publish: build publish
run:
@docker run -p 4000:4000 \
--volume="$(BUILD_DIR):$(GUEST_BUILD_DIR)" \
--volume="$(POSTS_DIR):$(GUEST_POSTS_DIR)" \
lfe/blog serve --watch --destination $(GUEST_BUILD_DIR)
new:
@docker run --entrypoint=rake \
--volume="$(POSTS_DIR):$(GUEST_POSTS_DIR)" \
lfe/blog post title="$(TITLE)"
post:
@OUT=$$($(MAKE) new | cut -d ' ' -f 4-) ; \
$(EDITOR) $(SRC)/$$OUT
publish:
-@cd $(PUBLISH_DIR) && \
git commit -am "Regenerated LFE blog content." > /dev/null && \
git push origin gh-pages
-@git add $(PUBLISH_DIR) && \
git commit -m "Updated submodule to recently published blog content." && \
git submodule update && \
git push origin master
clean-github-pages:
@rm -rf $(GITHUB_PAGES)
clean-build:
@rm -rf $(BUILD_DIR)
clean-all: clean-build clean-github-pages