Skip to content

Commit 10545f3

Browse files
author
Sameer Naik
authored
adds doc version selector dropdown (#353)
1 parent 07b3fe8 commit 10545f3

File tree

7 files changed

+56
-29
lines changed

7 files changed

+56
-29
lines changed

.dockerignore

-8
This file was deleted.

.github/workflows/build-and-release.yaml

+41-3
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,54 @@ jobs:
3737
runs-on: ubuntu-latest
3838
needs: build
3939
steps:
40+
4041
- name: Checkout
4142
uses: actions/checkout@v3
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Setup Python
47+
uses: actions/setup-python@v4
48+
with:
49+
python-version: '3.8'
50+
51+
- name: Install packages
52+
run: |
53+
git config --global url."https://${{ secrets.MKDOCS_INSIDERS_TOKEN }}@github".insteadOf https://github
54+
pip install git+https://github.com/squidfunk/mkdocs-material-insiders.git mkdocs-redirects mike
55+
56+
- name: Configure git credentials
57+
run: |
58+
git config --global user.name 'TriggerMesh Bot'
59+
git config --global user.email '[email protected]'
60+
61+
- name: Configure DOCS_VERSION
62+
id: docs-version
63+
run: |
64+
[[ "${GITHUB_REF_TYPE}" == "tag" ]] && DOCS_VERSION=${GITHUB_REF_NAME:1}
65+
echo "DOCS_VERSION=${DOCS_VERSION:-DEV}" >> $GITHUB_OUTPUT
66+
67+
- name: Deploy version and push
68+
run: |
69+
DOCS_VERSION="${{ steps.docs-version.outputs.DOCS_VERSION }}"
70+
if [[ "${DOCS_VERSION}" != "DEV" ]]; then
71+
mike deploy ${DOCS_VERSION} latest --update-aliases --push
72+
else
73+
mike deploy ${DOCS_VERSION}
74+
fi
75+
4276
- name: Set up Docker Buildx
4377
id: buildx
4478
uses: docker/setup-buildx-action@v2
79+
4580
- name: Login to GCR
4681
if: github.event_name != 'pull_request'
4782
uses: docker/login-action@v2
4883
with:
4984
registry: gcr.io
5085
username: _json_key
5186
password: ${{ secrets.GCLOUD_SERVICEACCOUNT_KEY }}
87+
5288
- name: Docker metadata
5389
id: meta
5490
uses: docker/metadata-action@v4
@@ -57,12 +93,14 @@ jobs:
5793
tags: |
5894
type=semver,pattern={{raw}}
5995
type=sha
60-
- name: Build image and push to container registries
96+
97+
- name: Switch to gh-pages branch
98+
run: git checkout gh-pages
99+
100+
- name: Build and push image
61101
uses: docker/build-push-action@v3
62102
with:
63103
context: .
64-
build-args: |
65-
MKDOCS_INSIDERS_TOKEN=${{ secrets.MKDOCS_INSIDERS_TOKEN }}
66104
push: ${{ github.event_name != 'pull_request' }}
67105
tags: ${{ steps.meta.outputs.tags }}
68106
labels: ${{ steps.meta.outputs.labels }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
.DS_Store
1414
/.idea/
1515
/.vscode/
16+
.envrc
1617

1718
# Build artifacts
1819
**/_output
20+
/site/

Dockerfile

-13
This file was deleted.

Makefile

+2-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ IMAGE_SHA ?= $(shell git rev-parse HEAD)
1717

1818
HAS_MKDOCS := $(shell command -v mkdocs;)
1919

20-
.PHONY: help build image cloudbuild-test cloudbuild clean
20+
.PHONY: help build cloudbuild-test cloudbuild clean
2121

2222
all: build
2323

2424
install-mkdocs:
2525
ifndef HAS_MKDOCS
26-
pip3 install mkdocs-material mkdocs-redirects
26+
pip3 install mkdocs-material mkdocs-redirects mike
2727
endif
2828

2929
help: ## Display this help
@@ -36,9 +36,6 @@ release: ## Build distribution tarball
3636
@mkdir -p $(DIST_DIR)
3737
tar -jcf $(DIST_DIR)/$(PACKAGE)-$(VERSION).tar.bz2 -C $$(dirname $(SITE_OUTPUT_DIR)) $$(basename $(SITE_OUTPUT_DIR))
3838

39-
image: ## Builds the container image
40-
$(DOCKER) build -t $(IMAGE_REPO)/$(PACKAGE) -f Dockerfile .
41-
4239
clean: ## Clean build artifacts
4340
@$(RM) -v $(DIST_DIR)/$(PACKAGE)-$(VERSION).tar.bz2
4441
@$(RM) -rv $(SITE_OUTPUT_DIR)

docs/overrides/main.html

+9
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@
1111
<strong>Twitter</strong>
1212
</a>
1313
{% endblock %}
14+
15+
{% block outdated %}
16+
You're not viewing the latest version.
17+
<a href="{{ '../' ~ base_url }}">
18+
19+
20+
<strong>Click here to go to latest.</strong>
21+
</a>
22+
{% endblock %}

mkdocs.yml

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ theme:
203203
- navigation.tracking
204204

205205
extra:
206+
version:
207+
provider: mike
206208
social:
207209
- icon: fontawesome/brands/github
208210
link: https://github.com/triggermesh

0 commit comments

Comments
 (0)