Skip to content

Commit 7319402

Browse files
henryiiiCopilot
andauthored
chore: show preview on docs changes (#5673)
* chore: show preview on docs changes Signed-off-by: Henry Schreiner <[email protected]> * Update .github/workflows/docs-link.yml Co-authored-by: Copilot <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 3867c5f commit 7319402

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/docs-link.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Read the Docs PR preview
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
documentation-links:
19+
runs-on: ubuntu-latest
20+
if: github.event.repository.fork == false
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Check for docs changes
25+
id: docs_changes
26+
run: |
27+
# Fetch the PR head
28+
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-head
29+
30+
# Show diff between base (current checkout) and PR head
31+
if git diff --name-only HEAD pr-head | grep -q '^docs/'; then
32+
echo "docs_changed=true" >> "$GITHUB_OUTPUT"
33+
else
34+
echo "docs_changed=false" >> "$GITHUB_OUTPUT"
35+
fi
36+
37+
- uses: readthedocs/actions/preview@v1
38+
if: steps.docs_changes.outputs.docs_changed == 'true'
39+
with:
40+
project-slug: "pybind11"
41+
single-version: "true"

0 commit comments

Comments
 (0)