Skip to content

Commit 36cdb9f

Browse files
TaiSakumaclaude
andauthored
feat: poll preview URL before posting PR comment (#14)
## Summary - Wait for the deployed preview to be live before posting the PR comment - Poll every 10 seconds, up to 5 minutes - If the site isn't ready after 5 minutes, post the comment with a note that it may not be ready yet ## Test plan - [ ] PR preview comment appears after the site is live - [ ] Comment does not include the "not ready" note under normal conditions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8781795 commit 36cdb9f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

.github/workflows/docs-pr-preview.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,21 @@ jobs:
3636
uses: actions/github-script@v7
3737
with:
3838
script: |
39-
const marker = '<!-- docs-preview -->';
4039
const url = '${{ steps.deploy.outputs.url }}';
41-
const body = `${marker}\n📖 Docs preview: ${url}`;
40+
41+
// Wait for deployment to be live (poll every 10s, up to 5 min)
42+
let live = false;
43+
for (let i = 0; i < 30; i++) {
44+
try {
45+
const res = await fetch(url);
46+
if (res.ok) { live = true; break; }
47+
} catch (e) {}
48+
await new Promise(r => setTimeout(r, 10000));
49+
}
50+
51+
const marker = '<!-- docs-preview -->';
52+
const status = live ? '' : '\n\n> **Note:** The preview may not be ready yet.';
53+
const body = `${marker}\n📖 Docs preview: ${url}${status}`;
4254
const { data: comments } = await github.rest.issues.listComments({
4355
owner: context.repo.owner,
4456
repo: context.repo.repo,

0 commit comments

Comments
 (0)