Skip to content

Commit bd36938

Browse files
committed
feat: add docs builder
1 parent a429562 commit bd36938

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/sphinx-docs.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# .github/workflows/sphinx-docs.yaml
2+
# Build Sphinx site for this Python package and publish it into your blog repo at:
3+
# https://diogoribeiro7.github.io/packages/your-python-package/
4+
# Requires a PAT with "repo" scope stored as PERSONAL_ACCESS_TOKEN in *this* repo.
5+
6+
name: sphinx-docs
7+
8+
on:
9+
push:
10+
branches: [main, develop]
11+
tags: ['*']
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
build-docs:
19+
runs-on: ubuntu-latest
20+
21+
concurrency:
22+
group: sphinx-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
env:
26+
BLOG_REPO: DiogoRibeiro7/DiogoRibeiro7.github.io
27+
BLOG_DEST: packages/your-python-package
28+
PYTHON_VERSION: '3.11'
29+
30+
steps:
31+
- name: Checkout package repository
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: ${{ env.PYTHON_VERSION }}
38+
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
pip install -r requirements.txt
43+
pip install sphinx sphinx-rtd-theme
44+
45+
- name: Build Sphinx docs
46+
run: |
47+
sphinx-build -b html docs/ site/
48+
49+
- name: Checkout blog repository
50+
uses: actions/checkout@v4
51+
with:
52+
repository: ${{ env.BLOG_REPO }}
53+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
54+
path: blog-repo
55+
56+
- name: Copy documentation to blog (includes dotfiles, cleans removed files)
57+
run: |
58+
mkdir -p "blog-repo/${BLOG_DEST}"
59+
rsync -av --delete site/ "blog-repo/${BLOG_DEST}/"
60+
ls -la "blog-repo/${BLOG_DEST}" | sed -n '1,80p'
61+
62+
- name: Commit and push changes to blog
63+
run: |
64+
cd blog-repo
65+
git config --local user.email "[email protected]"
66+
git config --local user.name "GitHub Action"
67+
git add .
68+
if git diff --staged --quiet; then
69+
echo "No changes to commit"
70+
else
71+
git commit -m "Update your-python-package Sphinx documentation"
72+
git push

0 commit comments

Comments
 (0)