cpu only torch docs build for git runner #34
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: | |
| # Runs on pushes targeting the default branch (main or master) | |
| push: | |
| branches: ["main", "master"] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| # Build job: builds the documentation and uploads it as an artifact. | |
| build: | |
| runs-on: ubuntu-latest | |
| # Set ENV vars at the job level to be inherited by all steps, including actions | |
| env: | |
| NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt | |
| SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt | |
| REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt | |
| # Use CPU-only PyTorch to save disk space | |
| PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu | |
| TORCH_CPU_ONLY: "true" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Install Act dependencies FIRST (before any apt-get commands) | |
| - name: Install Act dependencies | |
| if: ${{ env.ACT }} | |
| run: | | |
| # Ensure apt-get is available and install sudo for 'act' environments | |
| if ! command -v apt-get &> /dev/null; then | |
| echo "apt-get not found, cannot proceed" | |
| exit 1 | |
| fi | |
| # Install apt-utils first to avoid debconf warnings, then sudo | |
| DEBIAN_FRONTEND=noninteractive apt-get update && \ | |
| DEBIAN_FRONTEND=noninteractive apt-get install -y apt-utils sudo | |
| - name: Install Runner Dependencies & Configure CA | |
| run: | | |
| sudo apt-get update | |
| # Install lsb-release, Node.js, and ca-certificates all at once | |
| DEBIAN_FRONTEND=noninteractive sudo apt-get install -y lsb-release nodejs ca-certificates | |
| # Trust your mounted certificate (from the act command) | |
| sudo update-ca-certificates | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12.3' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: pip install -e .[docs] | |
| - name: Verify PyTorch installation | |
| run: | | |
| python -c "import torch; print(f'PyTorch version: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}')" | |
| - name: Build documentation | |
| run: sphinx-build -b html docs/source docs/build | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./docs/build | |
| # Deploy job for GitHub Pages | |
| deploy-github: | |
| needs: build | |
| if: ${{ vars.IS_GITEA != 'true' }} | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| env: | |
| NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt | |
| steps: | |
| - name: Install Act dependencies | |
| if: ${{ env.ACT }} | |
| run: | | |
| apt-get update && apt-get install -y sudo | |
| - name: Install Runner Dependencies & Configure CA | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y nodejs ca-certificates | |
| sudo update-ca-certificates | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| # Deploy job for Gitea | |
| deploy-gitea: | |
| needs: build | |
| if: ${{ vars.IS_GITEA == 'true' }} | |
| runs-on: ubuntu-latest | |
| env: | |
| NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt | |
| steps: | |
| - name: Install Act dependencies | |
| if: ${{ env.ACT }} | |
| run: | | |
| apt-get update && apt-get install -y sudo | |
| - name: Install Runner Dependencies & Configure CA | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y nodejs ca-certificates | |
| sudo update-ca-certificates | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: github-pages # This is the default artifact name for upload-pages-artifact | |
| path: ./docs-site | |
| - name: Deploy to Gitea docs location | |
| run: | | |
| echo "Deploying documentation to Gitea's special directory..." | |
| # The '/pages' directory is a mounted volume on the Gitea runner for serving static content. | |
| sudo mkdir -p /pages/ | |
| sudo cp -r ./docs-site/* /pages/ |