Skip to content

Join main.yml and pr.yml into top-level.yml #1

Join main.yml and pr.yml into top-level.yml

Join main.yml and pr.yml into top-level.yml #1

Workflow file for this run

on:
push:
branches:
- main
paths:
- 'docs/**'
pull_request:
paths:
- 'docs/**'
jobs:
build-doc:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: actions/checkout@v4
with:
lfs: 'true'
- name: Install pip packages
working-directory: docs
run: |
pip install pip --upgrade
pip install -r requirements.txt --upgrade
- name: Build doc
working-directory: docs
run: |
make html
- name: Store the generated doc
uses: actions/upload-artifact@v4
with:
name: html
path: docs/_build/html
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: [build-doc]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: 'gh-pages'
lfs: 'false'
- name: Empty gh-pages
run: |
git rm -r . --quiet
- uses: actions/download-artifact@v4
with:
name: html
- name: Patch doc build
run: |
rm -r _sources
touch .nojekyll
- name: Commit gh-pages
run: |
author=$(git log -1 --pretty=format:'%an')
email=$(git log -1 --pretty=format:'%ae')
commit=$(git rev-parse --short HEAD)
git add . >> /dev/null
git config --global user.name "$author"
git config --global user.email "$email"
git commit -m "deploy: $commit" --allow-empty
- name: Push to gh-pages
run: >-
git push origin gh-pages:gh-pages