Skip to content

sphinx-docs-to-gh-pages #31

sphinx-docs-to-gh-pages

sphinx-docs-to-gh-pages #31

name: sphinx-docs-to-gh-pages
on:
workflow_run:
workflows: ["CI"]
types: [completed]
branches: [master]
jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
env:
LAST_BUILD_FILE: last-build.html
steps:
- name: Checkout pywrparser master
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Build Sphinx html docs
run: poetry run sphinx-build -a docs/source docs/build/html
- name: Checkout pywrparser gh-pages
run: git clone -b gh-pages --single-branch https://token:${{ secrets.GITHUB_TOKEN }}@github.com/pmslavin/pywrparser.git gh-pages
- name: Copy doc changes
run: |
cp -r docs/build/html/* gh-pages
touch gh-pages/.nojekyll
echo "<p style='color:grey;font-size:8px'>Docs built from ${GITHUB_REF} commit ${GITHUB_SHA} at `git log -1 --pretty=%cd`</p>" > gh-pages/$LAST_BUILD_FILE
- name: Commit doc changes
run: |
cd gh-pages
git config --local user.email ${{ secrets.PAGES_EMAIL }}
git config --local user.name ${{ secrets.PAGES_USER }}
git add $LAST_BUILD_FILE
git commit -a -m "Sphinx workflow adds doc changes"
git push origin gh-pages