Skip to content

Commit 189c378

Browse files
hua7450claude
andcommitted
Deploy docs from the docs branch (not main) via gh-pages
Trigger the workflow on push to the docs branch instead of main, and switch from the GitHub Actions Pages artifact path to mkdocs' built-in gh-deploy command — which builds the site and force-pushes the result to a gh-pages branch. This keeps the docs source-of-truth on its own branch, with main completely untouched. The gh-pages branch is auto-managed; do not edit it directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b823d09 commit 189c378

1 file changed

Lines changed: 12 additions & 21 deletions

File tree

.github/workflows/docs.yml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ name: Build and deploy docs
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [docs]
66
paths:
77
- "docs/**"
88
- "mkdocs.yml"
99
- ".github/workflows/docs.yml"
1010
workflow_dispatch:
1111

1212
permissions:
13-
contents: read
14-
pages: write
15-
id-token: write
13+
contents: write # needed to push the built site to the gh-pages branch
1614

1715
concurrency:
18-
group: pages
16+
group: docs
1917
cancel-in-progress: false
2018

2119
jobs:
22-
build:
20+
deploy:
2321
runs-on: ubuntu-latest
2422
steps:
2523
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # gh-deploy needs full history to update gh-pages
2626

2727
- uses: actions/setup-python@v5
2828
with:
@@ -31,19 +31,10 @@ jobs:
3131
- name: Install MkDocs
3232
run: pip install mkdocs-material==9.5.34
3333

34-
- name: Build site
35-
run: mkdocs build --strict
36-
37-
- uses: actions/upload-pages-artifact@v3
38-
with:
39-
path: site
34+
- name: Configure git identity
35+
run: |
36+
git config user.name "github-actions[bot]"
37+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
4038
41-
deploy:
42-
needs: build
43-
runs-on: ubuntu-latest
44-
environment:
45-
name: github-pages
46-
url: ${{ steps.deployment.outputs.page_url }}
47-
steps:
48-
- id: deployment
49-
uses: actions/deploy-pages@v4
39+
- name: Build and push to gh-pages
40+
run: mkdocs gh-deploy --force

0 commit comments

Comments
 (0)