-
Notifications
You must be signed in to change notification settings - Fork 9
ci: add PR documentation preview workflow #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||||||
|
|
||||||
| 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
|
||||||
| 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 }}) | ||||||
|
||||||
| 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 }}) |
There was a problem hiding this comment.
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-commentcreate an issue comment via the Issues API. The workflow grantspull-requests: writebut notissues: write, which can cause the comment steps to fail with insufficient permissions. Addissues: write(and keep/removepull-requests: writeas needed).