Skip to content

Commit 18f3bc6

Browse files
committed
✨ Template: Add GitHub action for deploying docs on Github
Add a GitHub action to the template for both documentation tools to deploy the documentation to GitHub pages. This will run for any pushes on the `main` branch. The MkDocs action uses the `hatch docs:deploy` script, but the MyST deployment is more convoluted. For now we simply add an action based generated by the `myst init --gh-pages` command.
1 parent 2bceb61 commit 18f3bc6

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

copier.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ docs:
1616
- mkdocs
1717
default: myst
1818

19+
doc_deploy:
20+
type: str
21+
help: 'Where do you want to deploy your documentation?'
22+
choices:
23+
- nowhere
24+
- github
25+
default: nowhere
26+
1927
_subdirectory: template
2028
_message_after_copy: |
2129
The `{{package_name}}` package has been created successfully!
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy MyST site to Github pages
2+
on:
3+
push:
4+
# Runs on pushes targeting the default branch
5+
branches: [main]
6+
env:
7+
# `BASE_URL` determines, relative to the root of the domain, the URL that your site is served from.
8+
# E.g., if your site lives at `https://mydomain.org/myproject`, set `BASE_URL=/myproject`.
9+
# If, instead, your site lives at the root of the domain, at `https://mydomain.org`, set `BASE_URL=''`.
10+
BASE_URL: /${{ github.event.repository.name }}
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
18+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
19+
concurrency:
20+
group: 'pages'
21+
cancel-in-progress: false
22+
jobs:
23+
deploy:
24+
environment:
25+
name: github-pages
26+
url: ${{ steps.deployment.outputs.page_url }}
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Setup Pages
31+
uses: actions/configure-pages@v3
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 18.x
35+
- name: Install MyST
36+
run: npm install -g mystmd
37+
- name: Build HTML Assets
38+
run: myst build --html
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: './_build/html'
43+
- name: Deploy to GitHub Pages
44+
id: deployment
45+
uses: actions/deploy-pages@v4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Deploy MkDocs site to Github pages
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: 3.x
19+
20+
# Use configured `hatch` environment for MkDocs deployment
21+
- run: pip install hatch
22+
- run: hatch run docs:deploy

0 commit comments

Comments
 (0)