Skip to content

Fixing hosting issue in docs-preview #49

Fixing hosting issue in docs-preview

Fixing hosting issue in docs-preview #49

Workflow file for this run

on:
workflow_dispatch:
pull_request:
name: Preview Documentation
jobs:
render-docs-preview-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[docs]
- name: quartodoc build
run: |
quartodoc build
- name: Render Quarto Project
run: |
quarto render
# =====================================================
# Deploy to Netlify
# =====================================================
# Create a unique name for this deployment using the PR number
# This helps track which PR preview is which
- name: Configure release name
run: echo "RELEASE_NAME=pr-${{ github.event.pull_request.number || github.run_id }}" >> $GITHUB_ENV
# Create a deployment status on GitHub to track the deployment progress
# This shows up in the PR's "Deployments" section
- name: Create deployment status
uses: bobheadxi/deployments@v1
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.RELEASE_NAME }}
ref: ${{ github.head_ref || github.ref }}
logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
# Deploy the rendered site to Netlify with a PR-specific preview URL
# The alias ensures each PR gets its own stable URL during review
- name: Deploy to Netlify
id: netlify
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: |
npm install -g netlify-cli
ALIAS="pr-${{ github.event.pull_request.number || github.run_id }}"
netlify deploy --dir=_site --alias="$ALIAS" --json > deploy.json
DEPLOY_URL=$(python -c "import json; d=json.load(open('deploy.json')); \
print(d.get('deploy_ssl_url') or d.get('deploy_url') or '')")
echo "url=${DEPLOY_URL}" >> $GITHUB_OUTPUT
# Update the GitHub deployment status with success/failure and the preview URL
# This creates a clickable link in the PR to view the deployed preview
- name: Update deployment status
uses: bobheadxi/deployments@v1
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env: ${{ steps.deployment.outputs.env }}
env_url: ${{ steps.netlify.outputs.url }}
logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'