Skip to content
Merged
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
22 changes: 14 additions & 8 deletions .github/workflows/docs-pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,30 @@ jobs:
target: pr/${{ github.event.number }}
commit-message: "Deploy PR #${{ github.event.number }} preview"

- name: Post or update PR comment
- name: Wait for deployment
id: wait
uses: actions/github-script@v7
with:
script: |
const url = '${{ steps.deploy.outputs.url }}';

// Wait for deployment to be live (poll every 10s, up to 5 min)
let live = false;
for (let i = 0; i < 30; i++) {
const maxAttempts = 30;
const intervalMs = 10_000;
for (let i = 0; i < maxAttempts; i++) {
try {
const res = await fetch(url);
if (res.ok) { live = true; break; }
if (res.ok) { core.setOutput('live', 'true'); return; }
} catch (e) {}
await new Promise(r => setTimeout(r, 10000));
await new Promise(r => setTimeout(r, intervalMs));
}
core.setOutput('live', 'false');

- name: Post or update PR comment
uses: actions/github-script@v7
with:
script: |
const url = '${{ steps.deploy.outputs.url }}';
const marker = '<!-- docs-preview -->';
const status = live ? '' : '\n\n> **Note:** The preview may not be ready yet.';
const status = '${{ steps.wait.outputs.live }}' === 'true' ? '' : '\n\n> **Note:** The preview may not be ready yet.';
const body = `${marker}\n📖 Docs preview: ${url}${status}`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
Expand Down
Loading