Skip to content

Commit 95dc66e

Browse files
committed
Upgrade docs.
1 parent f03299b commit 95dc66e

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Preview comment
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
pull-requests: write
9+
10+
jobs:
11+
comment:
12+
name: Post preview URL
13+
runs-on: ubuntu-latest
14+
# Only run on PRs from the same repo (not forks)
15+
if: github.event.pull_request.head.repo.full_name == github.repository
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Extract deploy repo from make.jl
22+
id: deploy
23+
run: |
24+
# Looks for: deploy_repo = "github.com/owner/repo.git"
25+
DEPLOY_REPO=$(grep -oP 'deploy_repo\s*=\s*"github\.com/\K[^"]+' docs/make.jl | sed 's/\.git$//' || true)
26+
27+
if [ -n "$DEPLOY_REPO" ]; then
28+
echo "repo=$DEPLOY_REPO" >> "$GITHUB_OUTPUT"
29+
else
30+
# No cross-repo deployment found, fall back to the source repo
31+
echo "repo=${{ github.repository }}" >> "$GITHUB_OUTPUT"
32+
fi
33+
34+
- name: Comment preview URL
35+
uses: actions/github-script@v7
36+
env:
37+
DEPLOY_REPO: ${{ steps.deploy.outputs.repo }}
38+
with:
39+
script: |
40+
const pr = context.issue.number;
41+
const [deployOwner, deployRepoName] = process.env.DEPLOY_REPO.split("/");
42+
43+
const previewUrl = `https://${deployOwner}.github.io/${deployRepoName}/previews/PR${pr}/`;
44+
const marker = "<!-- documenter-preview-comment -->";
45+
const body = [
46+
marker,
47+
"### 📚 Documentation preview 🚀",
48+
"",
49+
`**Preview URL:** [${previewUrl}](${previewUrl})`,
50+
"",
51+
"> [!NOTE]",
52+
"> The preview will be available once the documentation build completes successfully, and will reflect the last successful build for this PR.",
53+
].join("\n");
54+
55+
const { data: comments } = await github.rest.issues.listComments({
56+
owner: context.repo.owner,
57+
repo: context.repo.repo,
58+
issue_number: pr,
59+
});
60+
61+
const existing = comments.find((c) => c.body?.includes(marker));
62+
63+
if (!existing) {
64+
await github.rest.issues.createComment({
65+
owner: context.repo.owner,
66+
repo: context.repo.repo,
67+
issue_number: pr,
68+
body,
69+
});
70+
}

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Shapefile = "8e980c4a-a4fe-5da2-b3a7-4b4b0353a2f4"
1818

1919
[compat]
2020
Documenter = "1"
21-
DocumenterVitepress = "0.2.6"
21+
DocumenterVitepress = "0.3"

0 commit comments

Comments
 (0)