Skip to content

Commit 36a902e

Browse files
committed
add deploy command & remove unnecessary commands
1 parent 845a911 commit 36a902e

File tree

4 files changed

+28
-50
lines changed

4 files changed

+28
-50
lines changed

docs.mk

+15-40
Original file line numberDiff line numberDiff line change
@@ -25,74 +25,50 @@ SERVE_BIND_ADDRESS ?= 127.0.0.1
2525
TOP := $(dir $(firstword $(MAKEFILE_LIST)))
2626
# DOCROOT is the root of the mkdocs tree.
2727
DOCROOT := $(abspath $(TOP))
28-
# GENROOT is the root of the generated documentation.
29-
GENROOT := $(DOCROOT)/docs
3028

3129
# Grab the uid/gid to fix permissions due to running in a docker container.
3230
GID := $(shell id -g)
3331
UID := $(shell id -u)
3432

3533
# SOURCES is a list of a source files used to generate the documentation.
36-
SOURCES := $(shell find $(DOCROOT)/docs-src -name \*.md)
34+
SOURCES := $(shell find $(DOCROOT)/docs -name \*.md)
3735
SOURCES += mkdocs.yml docs.mk
3836

3937
# entrypoint
40-
all: .mkdocs.timestamp
38+
all:
4139

4240
# Support docker images.
4341
.PHONY: images
4442
images: .mkdocs.dockerfile.timestamp
4543

4644
# build the image for mkdocs
47-
.mkdocs.dockerfile.timestamp: mkdocs.dockerfile
45+
.mkdocs.dockerfile.timestamp: mkdocs.dockerfile mkdocs.requirements.txt
4846
docker build -t $(MKDOCS_IMAGE) -f mkdocs.dockerfile .
4947
date > $@
5048

51-
# generate the `docs` from SOURCES
52-
.mkdocs.timestamp: images $(SOURCES)
49+
# serve runs mkdocs as a local webserver for interactive development.
50+
# This will serve the live copy of the docs on 127.0.0.1:8000.
51+
.PHONY: serve
52+
serve: images
5353
$(DOCKER) run \
54-
--mount type=bind,source=$(DOCROOT),target=/d \
54+
-it \
5555
--sig-proxy=true \
56-
--rm \
57-
$(MKDOCS_IMAGE) \
58-
/bin/bash -c "cd /d && $(MKDOCS) build; find /d/docs -exec chown $(UID):$(GID) {} \;"
59-
# Remove sitemap as it contains the timestamp, which is a source of a lot
60-
# of merge conflicts.
61-
rm docs/sitemap.xml docs/sitemap.xml.gz
62-
date > $@
63-
64-
.PHONY: verify
65-
# verify that the docs have been properly updated.
66-
#
67-
# docs-src/.mkdocs-exclude contains a list of `diff -X` files to
68-
# exclude from the verification diff.
69-
verify: images
70-
$(DOCKER) run \
7156
--mount type=bind,source=$(DOCROOT),target=/d \
72-
--sig-proxy=true \
57+
-p $(SERVE_BIND_ADDRESS):8000:8000 \
7358
--rm \
7459
$(MKDOCS_IMAGE) \
75-
/bin/bash -c "cd /d && $(MKDOCS) build --site-dir=/tmp/d && diff -X /d/docs-src/.mkdocs-exclude -qr /d/docs /tmp/d"
76-
77-
# clean deletes generated files
78-
.PHONY: clean
79-
clean:
80-
test -f .mkdocs.timestamp && rm .mkdocs.timestamp || true
81-
test -f .mkdocs.dockerfile.timestamp && rm .mkdocs.dockerfile.timestamp || true
82-
rm -r $(GENROOT)/* || true
60+
/bin/bash -c "cd /d && $(MKDOCS) serve -a 0.0.0.0:8000"
8361

84-
# serve runs mkdocs as a local webserver for interactive development.
85-
# This will serve the live copy of the docs on 127.0.0.1:8000.
86-
.PHONY: images serve
87-
serve:
62+
# deploy will publish generated docs into gh-pages branch.
63+
.PHONY: deploy
64+
deploy: images
8865
$(DOCKER) run \
8966
-it \
9067
--sig-proxy=true \
9168
--mount type=bind,source=$(DOCROOT),target=/d \
92-
-p $(SERVE_BIND_ADDRESS):8000:8000 \
9369
--rm \
9470
$(MKDOCS_IMAGE) \
95-
/bin/bash -c "cd /d && $(MKDOCS) serve -a 0.0.0.0:8000"
71+
/bin/bash -c "cd /d && git config --global url."https://$$GITHUB_USER:$$GITHUB_TOKEN@github.com/".pushInsteadOf "https://github.com/" && $(MKDOCS) gh-deploy"
9672

9773
# help prints usage for this Makefile.
9874
.PHONY: help
@@ -101,8 +77,8 @@ help:
10177
@echo ""
10278
@echo "make Build the documentation"
10379
@echo "make help Print this help message"
104-
@echo "make clean Delete generated files"
10580
@echo "make serve Run the webserver for live editing (ctrl-C to quit)"
81+
@echo "make deploy Publish generated docs into gh-pages branch"
10682

10783
# init creates a new mkdocs template. This is included for completeness.
10884
.PHONY: images init
@@ -113,4 +89,3 @@ init:
11389
--rm \
11490
$(MKDOCS_IMAGE) \
11591
/bin/bash -c "$(MKDOCS) new d; find /d -exec chown $(UID):$(GID) {} \;"
116-

mkdocs.dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ FROM alpine:3.11
1616
COPY mkdocs.requirements.txt /
1717
RUN apk add -U --no-cache \
1818
python3 \
19+
git \
1920
bash \
2021
diffutils \
22+
git \
23+
git-fast-import \
2124
&& pip3 install -r /mkdocs.requirements.txt

mkdocs.requirements.txt

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
Click==7.0
2+
future==0.18.2
23
htmlmin==0.1.12
3-
Jinja2==2.10.3
4+
Jinja2==2.11.1
45
jsmin==2.2.2
56
livereload==2.6.1
6-
Markdown==3.1.1
7+
lunr==0.5.6
8+
Markdown==3.2.1
79
MarkupSafe==1.1.1
8-
mkdocs==1.0.4
9-
mkdocs-material==4.6.0
10-
mkdocs-minify-plugin==0.2.1
11-
pep562==1.0
10+
mkdocs==1.1
11+
mkdocs-material==4.6.3
12+
mkdocs-minify-plugin==0.2.3
13+
nltk==3.4.5
1214
Pygments==2.5.2
13-
pymdown-extensions==6.2.1
15+
pymdown-extensions==6.3
1416
PyYAML==5.3
1517
six==1.14.0
16-
tornado==6.0.3
18+
tornado==6.0.3

mkdocs.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
site_name: Kubernetes Service API Evolution
22
repo_url: http://sigs.k8s.io/service-apis
3-
site_dir: docs
4-
docs_dir: docs-src
53
theme:
64
name: material
75
nav:

0 commit comments

Comments
 (0)