Use github action to deploy pages, give up on muli-version docs #11
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 docs | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
build_docs: | |
name: Build docs | |
runs-on: ubuntu-latest | |
steps: | |
- name: Avoid git conflicts when tag and branch pushed at same time | |
if: github.ref_type == 'tag' | |
run: sleep 60 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.12 | |
- name: Install ffmpeg | |
uses: FedericoCarboni/setup-ffmpeg@v3 | |
- name: Install opencv | |
run: python -m pip install opencv-python-headless ipywidgets | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install optimap | |
run: python -m pip install .[docs] | |
- name: Cache file downloads and jupyter notebook execution | |
uses: actions/cache@v4 | |
with: | |
path: | | |
docs/tutorials/optimap_example_data | |
docs/_build/.jupyter_cache | |
key: docs-example-files | |
- name: Build docs | |
run: python -m sphinx -b dirhtml docs docs/_build/html | |
# - name: Upload artifact | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# path: docs/_build/html | |
# name: juypter_cache | |
- name: Sanitize ref name for docs version | |
run: echo "DOCS_VERSION=${GITHUB_REF_NAME//[^A-Za-z0-9._-]/_}" >> $GITHUB_ENV | |
- name: Move to versioned directory | |
run: mv docs/_build/html .github/pages/$DOCS_VERSION | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: .github/pages | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build_docs | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |