WIP docs: Add skeleton for GitHub Actions workflow to build docs #5
This file contains hidden or 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 and Deploy Documentation | |
| on: | |
| # Build preview documentation for pull requests | |
| pull_request: | |
| # Build and deploy documentation for master branch | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| build-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y doxygen graphviz | |
| - name: Install Python dependencies | |
| working-directory: docs | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Build documentation | |
| working-directory: docs | |
| run: | | |
| chmod +x build_docs.sh | |
| ./build_docs.sh | |
| - name: Upload documentation artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docs | |
| path: | | |
| docs/_build | |
| !docs/_build/.doctrees | |
| deploy-docs: | |
| needs: build-docs | |
| runs-on: ubuntu-latest | |
| # Set Deploy environment for master branch, otherwise set Preview environment | |
| environment: ${{ github.ref_name == 'master' && 'esp-docs deploy' || 'esp-docs preview' }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: docs | |
| path: docs/_build | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Python dependencies | |
| working-directory: docs | |
| run: | | |
| pip install -r requirements.txt | |
| - name: Get git version | |
| id: git_version | |
| run: | | |
| git_ver=$(git describe --always) | |
| echo "version=$git_ver" >> $GITHUB_OUTPUT | |
| echo "GIT_VER=$git_ver" >> $GITHUB_ENV | |
| - name: Deploy documentation | |
| working-directory: docs | |
| shell: bash | |
| env: | |
| GIT_VER: ${{ steps.git_version.outputs.version }} | |
| DOCS_BUILD_DIR: ${{ github.workspace }}/docs/_build | |
| DOCS_DEPLOY_URL_BASE: ${{ vars.DOCS_URL_BASE }} | |
| DOCS_DEPLOY_SERVER: ${{ vars.DOCS_SERVER }} | |
| DOCS_DEPLOY_SERVER_USER: ${{ secrets.DOCS_SERVER_USER }} | |
| DOCS_DEPLOY_PATH: ${{ vars.DOCS_PATH }} | |
| DOCS_DEPLOY_PRIVATEKEY: ${{ secrets.DOCS_PRIVATEKEY }} | |
| # TYPE is optional - only used for output formatting (shows "deploy" or "preview" in logs) | |
| TYPE: ${{ github.ref_name == 'master' && 'deploy' || 'preview' }} | |
| run: | | |
| source $GITHUB_WORKSPACE/docs/utils.sh | |
| add_doc_server_ssh_keys "$DOCS_DEPLOY_PRIVATEKEY" "$DOCS_DEPLOY_SERVER" "$DOCS_DEPLOY_SERVER_USER" | |
| deploy-docs |