Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: PR Documentation Preview

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read
pull-requests: write
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

peter-evans/find-comment / create-or-update-comment create an issue comment via the Issues API. The workflow grants pull-requests: write but not issues: write, which can cause the comment steps to fail with insufficient permissions. Add issues: write (and keep/remove pull-requests: write as needed).

Suggested change
pull-requests: write
pull-requests: write
issues: write

Copilot uses AI. Check for mistakes.

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
build-and-preview:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Build HTML documentation
run: make html

- name: Upload HTML artifact
uses: actions/upload-artifact@v4
with:
name: html-docs-pr-${{ github.event.pull_request.number }}
path: build/html/
retention-days: 7

- name: Find existing comment
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Documentation Preview'

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
Comment on lines +40 to +53
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On pull_request events from forks, GITHUB_TOKEN is read-only and cannot write PR/issue comments. Without a guard, the comment steps will fail and the whole job will be marked failed for fork PRs. Consider gating the find/create comment steps to same-repo PRs (e.g. only when github.event.pull_request.head.repo.full_name == github.repository) or making the comment steps non-fatal.

Copilot uses AI. Check for mistakes.
body: |
## Documentation Preview

HTML documentation has been built for this PR.

**Download the preview:**
1. Go to [Artifacts](#{{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Artifacts link in the PR comment is prefixed with #, which turns it into a page fragment (e.g. #https://...) instead of a navigable URL. Remove the leading # so the link points to the workflow run URL directly.

Suggested change
1. Go to [Artifacts](#{{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
1. Go to [Artifacts](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

Copilot uses AI. Check for mistakes.
2. Download `html-docs-pr-${{ github.event.pull_request.number }}`
3. Extract and open `index.html` in browser

| Property | Value |
| --- | --- |
| Run ID | ${{ github.run_id }} |
| Commit | ${{ github.event.pull_request.head.sha }} |