Skip to content

Commit f681fce

Browse files
committed
Add GitHub Actions workflow for documentation generation
1 parent 875985b commit f681fce

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

.github/workflows/docs.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: CI Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build-docs:
11+
name: "Build Docs"
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
with:
16+
fetch-depth: 0 # Full history for accurate page timestamps
17+
18+
- uses: actions/setup-python@v6
19+
with:
20+
python-version: "3.11"
21+
22+
- name: Install package and dependencies
23+
run: |
24+
python -m pip install uv
25+
uv sync
26+
uv pip install great-docs
27+
28+
- name: Set up Quarto
29+
uses: quarto-dev/quarto-actions/setup@v2
30+
31+
- name: Build docs
32+
run: uv run great-docs build
33+
34+
- name: Save docs artifact
35+
uses: actions/upload-artifact@v7
36+
with:
37+
name: docs-html
38+
path: great-docs/_site
39+
include-hidden-files: true
40+
41+
- name: Upload build timings
42+
uses: actions/upload-artifact@v7
43+
with:
44+
name: build-timings
45+
path: great-docs/_site/build-timings.json
46+
47+
publish-docs:
48+
name: "Publish Docs"
49+
runs-on: ubuntu-latest
50+
needs: "build-docs"
51+
if: github.ref == 'refs/heads/main'
52+
permissions:
53+
pages: write
54+
id-token: write
55+
environment:
56+
name: github-pages
57+
url: ${{ steps.deployment.outputs.page_url }}
58+
steps:
59+
- uses: actions/download-artifact@v7
60+
with:
61+
name: docs-html
62+
path: great-docs/_site
63+
64+
- name: Upload Pages artifact
65+
uses: actions/upload-pages-artifact@v5
66+
with:
67+
path: great-docs/_site
68+
include-hidden-files: true
69+
70+
- name: Deploy to GitHub Pages
71+
id: deployment
72+
uses: actions/deploy-pages@v5
73+
74+
preview-docs:
75+
name: "Preview Docs"
76+
runs-on: ubuntu-latest
77+
needs: "build-docs"
78+
if: github.event_name == 'pull_request'
79+
permissions:
80+
deployments: write
81+
pull-requests: write
82+
steps:
83+
- uses: actions/download-artifact@v7
84+
with:
85+
name: docs-html
86+
path: great-docs/_site
87+
88+
# Start deployment
89+
- name: Configure pull release name
90+
if: ${{ github.event_name == 'pull_request' }}
91+
run: |
92+
echo "RELEASE_NAME=pr-${{ github.event.number }}" >> $GITHUB_ENV
93+
94+
- name: Configure branch release name
95+
if: ${{ github.event_name != 'pull_request' }}
96+
run: |
97+
# use branch name, but replace slashes. E.g. feat/a -> feat-a
98+
echo "RELEASE_NAME=${GITHUB_REF_NAME//\//-}" >> $GITHUB_ENV
99+
100+
# Deploy
101+
- name: Create Github Deployment
102+
uses: bobheadxi/deployments@v1
103+
id: deployment
104+
if: ${{ !github.event.pull_request.head.repo.fork }}
105+
with:
106+
step: start
107+
token: ${{ secrets.GITHUB_TOKEN }}
108+
env: ${{ env.RELEASE_NAME }}
109+
ref: ${{ github.head_ref }}
110+
logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"

0 commit comments

Comments
 (0)