Website update #147
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: "Website update" | |
on: | |
push: | |
branches: | |
- "**" | |
- "!gh-pages" | |
pull_request: | |
branches: | |
- main | |
schedule: | |
- cron: "0 2 * * SUN" | |
workflow_dispatch: | |
jobs: | |
website: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone website repository on current branch | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Clone website repository on gh-pages branch | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
fetch-depth: 0 | |
path: _build/html | |
- name: Install dependencies | |
run: | | |
pip3 -q install sphinx-material sphinxcontrib-bibtex | |
- name: Generate sphinx website | |
run: | | |
rm -rf _build/html/* && python3 -m sphinx -W -b html . _build/html | |
- name: Fix permissions and add CNAME file | |
run: | | |
sudo chown $USER _build -R | |
echo "www.rbnicsproject.org" > _build/html/CNAME | |
- name: Remove unnecessary .doctrees folder | |
run: | | |
rm -rf _build/html/.doctrees | |
- name: Deploy to GitHub pages | |
if: github.repository == 'RBniCS/rbnicsproject.org' && github.ref == 'refs/heads/main' | |
run: | | |
SHA_SHORT=$(git rev-parse --short HEAD) | |
pushd _build/html | |
git config user.name "GitHub Actions" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add . | |
git pull origin gh-pages | |
[ -n "$(git status --porcelain=v1 2>/dev/null)" ] && git commit -m "deploy: ${SHA_SHORT}" | |
git push origin gh-pages | |
popd | |
shell: bash | |
- name: Deploy to GitHub artifacts | |
if: github.repository == 'RBniCS/rbnicsproject.org' && github.ref != 'refs/heads/main' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: website | |
path: | | |
_build/html | |
!_build/html/.git | |
retention-days: 1 | |
warn: | |
runs-on: ubuntu-latest | |
if: github.repository == 'RBniCS/rbnicsproject.org' && github.ref == 'refs/heads/main' && github.event_name == 'schedule' | |
steps: | |
- name: Warn if scheduled workflow is about to be disabled | |
uses: fem-on-colab/warn-workflow-about-to-be-disabled-action@main | |
with: | |
workflow-filename: website.yml | |
days-elapsed: 50 |