Add build doc workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Doc | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'docs/**' | |
jobs: | |
build: | |
name: Deploy doc | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
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: Commit | |
run: | | |
author=$(git log -1 --pretty=format:'%an') | |
email=$(git log -1 --pretty=format:'%ae') | |
commit=$(git rev-parse --short HEAD) | |
mkdir /tmp/doc | |
rm -r docs/_build/html/_sources | |
cp -r docs/_build/html/* /tmp/doc | |
git stash --all | |
git fetch origin gh-pages | |
git checkout -b gh-pages origin/gh-pages | |
git rm -r . --quiet | |
cp -r /tmp/doc/* . | |
touch .nojekyll | |
git lfs uninstall | |
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 | |
- name: Clean-up | |
run: >- | |
rm -r /tmp/doc |