Skip to content

Commit 3181015

Browse files
authored
Set up MkDocs publishing on CI (#721)
* Set up MkDocs publishing on CI * Delete deploy_website.sh
1 parent 2a2d4f8 commit 3181015

3 files changed

Lines changed: 58 additions & 51 deletions

File tree

.buildscript/prepare_mkdocs.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# The website is built using MkDocs with the Material theme.
4+
# https://squidfunk.github.io/mkdocs-material/
5+
# It requires Python to run.
6+
# Install the packages with the following command:
7+
# pip install mkdocs mkdocs-material
8+
9+
set -ex
10+
11+
# Generate the API docs
12+
./gradlew okio:dokka
13+
14+
# Dokka filenames like `-http-url/index.md` don't work well with MkDocs <title> tags.
15+
# Assign metadata to the file's first Markdown heading.
16+
# https://www.mkdocs.org/user-guide/writing-your-docs/#meta-data
17+
title_markdown_file() {
18+
TITLE_PATTERN="s/^[#]+ *(.*)/title: \1 - Okio/"
19+
echo "---" > "$1.fixed"
20+
cat $1 | sed -E "$TITLE_PATTERN" | grep "title: " | head -n 1 >> "$1.fixed"
21+
echo "---" >> "$1.fixed"
22+
echo >> "$1.fixed"
23+
cat $1 >> "$1.fixed"
24+
mv "$1.fixed" "$1"
25+
}
26+
27+
set +x
28+
for MARKDOWN_FILE in $(find docs/2.x/ -name '*.md'); do
29+
echo $MARKDOWN_FILE
30+
title_markdown_file $MARKDOWN_FILE
31+
done
32+
set -x
33+
34+
# Copy in special files that GitHub wants in the project root.
35+
cat README.md | grep -v 'project website' > docs/index.md
36+
cp CHANGELOG.md docs/changelog.md
37+
cp CONTRIBUTING.md docs/contributing.md

.github/workflows/build.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,24 @@ jobs:
8585
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
8686
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
8787

88-
# TODO(egorand): Publish website
89-
#
90-
# - name: Prep mkdocs
91-
# run: .buildscript/prepare_mkdocs.sh
92-
#
93-
# - name: Deploy docs
94-
# uses: mhausenblas/mkdocs-deploy-gh-pages@master
95-
# env:
96-
# PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
88+
- name: Prepare docs
89+
run: .buildscript/prepare_mkdocs.sh
90+
91+
- name: Deploy docs
92+
uses: mhausenblas/mkdocs-deploy-gh-pages@v1.12
93+
env:
94+
PERSONAL_TOKEN: ${{ secrets.GH_CLIPPY_TOKEN }}
95+
96+
- name: Checkout gh-pages
97+
uses: actions/checkout@v2
98+
with:
99+
ref: 'gh-pages'
100+
101+
- name: Restore Javadocs from 1.x
102+
run: git cherry-pick b3205fa199a19d6fbf13ee5c8e0c3d6d2b15b05f
103+
104+
- name: Push gh-pages
105+
uses: ad-m/github-push-action@v0.5.0
106+
with:
107+
branch: gh-pages
108+
github_token: ${{ secrets.GH_CLIPPY_TOKEN }}

deploy_website.sh

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)