Skip to content

feat: build docs

feat: build docs #1

Workflow file for this run

# .github/workflows/sphinx-docs.yaml
# Build Sphinx site for this Python package and publish it into your blog repo at:
# https://diogoribeiro7.github.io/packages/your-python-package/
# Requires a PAT with "repo" scope stored as PERSONAL_ACCESS_TOKEN in *this* repo.
name: sphinx-docs
on:
push:
branches: [main, develop]
tags: ['*']
workflow_dispatch:
permissions:
contents: write
jobs:
build-docs:
runs-on: ubuntu-latest
concurrency:
group: sphinx-${{ github.ref }}
cancel-in-progress: true
env:
BLOG_REPO: DiogoRibeiro7/DiogoRibeiro7.github.io
BLOG_DEST: packages/gensurvpy
PYTHON_VERSION: '3.11'
steps:
- name: Checkout package repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install sphinx sphinx-rtd-theme
- name: Build Sphinx docs
run: |
sphinx-build -b html docs/ site/
- name: Checkout blog repository
uses: actions/checkout@v4
with:
repository: ${{ env.BLOG_REPO }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
path: blog-repo
- name: Copy documentation to blog (includes dotfiles, cleans removed files)
run: |
mkdir -p "blog-repo/${BLOG_DEST}"
rsync -av --delete site/ "blog-repo/${BLOG_DEST}/"
ls -la "blog-repo/${BLOG_DEST}" | sed -n '1,80p'
- name: Commit and push changes to blog
run: |
cd blog-repo
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Update your-python-package Sphinx documentation"
git push