Add GitHub Actions workflow for PR preview deployments #3
Workflow file for this run
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: Deploy PR Preview | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - closed | |
| concurrency: | |
| group: preview-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| deploy-preview: | |
| name: Deploy PR Preview | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Clone repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| if: github.event.action != 'closed' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| - name: Install Node.js dependencies | |
| if: github.event.action != 'closed' | |
| run: npm ci | |
| - name: Build assets | |
| if: github.event.action != 'closed' | |
| run: npm run build | |
| - name: Set up Python | |
| if: github.event.action != 'closed' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.x | |
| - name: Get cache ID | |
| if: github.event.action != 'closed' | |
| run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | |
| - name: Restore cache | |
| if: github.event.action != 'closed' | |
| uses: actions/cache@v4 | |
| with: | |
| key: mkdocs-material-${{ env.cache_id }} | |
| path: .cache | |
| restore-keys: | | |
| mkdocs-material- | |
| - name: Install MkDocs | |
| if: github.event.action != 'closed' | |
| run: pip install 'mkdocs-material>=9.0.0,<10.0.0' | |
| - name: Build docs | |
| if: github.event.action != 'closed' | |
| run: mkdocs build | |
| - name: Deploy or destroy preview | |
| uses: rossjrw/pr-preview-action@v1 | |
| with: | |
| wait-for-pages-deployment: true | |
| source-dir: site/ | |
| preview-branch: gh-pages | |
| umbrella-dir: pr-preview | |
| action: auto |