Skip to content

Commit 71b4558

Browse files
authored
Auto-deploy documentation
1 parent ccb33a7 commit 71b4558

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

.github/workflows/docs.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Publish documentation to GitHub Pages
2+
on:
3+
workflow_call:
4+
push:
5+
branches:
6+
- main
7+
permissions:
8+
contents: write
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: 3.12
18+
- name: Configure Git Credentials
19+
run: |
20+
git config user.name github-actions[bot]
21+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
22+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
23+
- uses: actions/cache@v4
24+
with:
25+
key: mkdocs-material-${{ env.cache_id }}
26+
path: .cache
27+
restore-keys: |
28+
mkdocs-material-
29+
- name: Install dependencies
30+
run: pip install mkdocs-material mkdocstrings[python]
31+
- name: Publish to GitHub Pages
32+
run: mkdocs gh-deploy --force

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ coverage:
5151
test: coverage
5252

5353
.PHONY: docs
54-
docs: # Build documentation site
55-
poetry run mkdocs build
54+
docs: # Build and deploy documentation to GitHub pages
55+
poetry run mkdocs gh-deploy --force
5656

5757
local: # Serve documentation on a local server
5858
poetry run mkdocs serve

docs/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ A Python project template that comes out of the box with configuration for:
1414
- Automated dependency update using [Dependabot](https://docs.github.com/en/code-security/dependabot)
1515
- Dockerized development environment using [Dev containers](https://code.visualstudio.com/docs/devcontainers/containers)
1616
- Automatic documentation from code using [mkdocs](https://www.mkdocs.org) and [mkdocstrings](https://mkdocstrings.github.io)
17+
- Documentation auto-deployment to [GiHub Pages](https://pages.github.com)
1718
- App container using [Docker](https://docker.com)
1819

1920
## How to use
@@ -112,10 +113,14 @@ docker compose run app -h
112113
```
113114

114115
## Generating documentation
115-
To generate the project documentation, run:
116+
To generate and publish the project documentation to GitHub pages, run:
116117
```bash
117118
make docs
118119
```
120+
That pushes the new documentation to the gh-pages branch.
121+
Make sure GitHub Pages is enableed in your repository settings and using the gh-pages branch for the documentation to be publicly available.
122+
123+
### Local
119124
To serve the documentation on a local server, run:
120125
```bash
121126
make local
@@ -131,7 +136,8 @@ make local
131136
│ ├── dependabot.yaml # Dependabot configuration
132137
│ ├── FUNDING.md # GitHub funding
133138
│ └── workflows # Github Actions Workflows
134-
│ └── check.yml # Workflow to validate code on push
139+
| ├── check.yml # Workflow to validate code on push
140+
│ └── docs.yml # Woukflow to publish documentation
135141
├── .gitignore # Git-ignored file list
136142
├── .pre-commit-config.yaml # Pre-commit configuration file
137143
├── .flake8 # flake8 configuration file

mkdocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ theme:
2222
- search.suggest
2323
- toc.follow
2424

25-
2625
nav:
2726
- Overview: README.md
2827
- Reference:

0 commit comments

Comments
 (0)