From 682d0a841278546f053d66e6e27828b3c30b2e2d Mon Sep 17 00:00:00 2001 From: Hannes Lenke Date: Sat, 7 Nov 2026 20:34:48 -0500 Subject: [PATCH 1/2] ci(preview-checks): resolve the preview URL from the deployment check-run Mintlify sometimes posts a second preview comment and keeps updating the first one. Picking the newest comment by creation time then polled a frozen "Building" comment until the step timed out (#446, #610, #669). Take the URL from the Mintlify Deployment check-run for the head commit, which names the preview it built. The comment fallback, still used when the site didn't change, now pages through all comments and takes the most recently updated one. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/preview-checks.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/preview-checks.yml b/.github/workflows/preview-checks.yml index 6c3e2942..48d72ebc 100644 --- a/.github/workflows/preview-checks.yml +++ b/.github/workflows/preview-checks.yml @@ -74,12 +74,15 @@ jobs: TIMEOUT=1200 # 20 min for a deployment to finish SLEEP=15 elapsed=0 + PREVIEW_URL_RE='https://[a-z0-9-]+\.(mintlify\.(app|site)|mintlifysite\.com)' # Exits with the preview URL when the PR's preview is ready, fails # when it failed, and returns while it is still building. read_preview() { - COMMENT_BODY=$(gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \ - --jq '[.[] | select(.user.login == "mintlify[bot]" and (.body | contains("mintlify-preview-comment")))] | last | .body // empty') + # Mintlify sometimes posts a second preview comment and keeps + # updating the first, so take the most recently updated one. + COMMENT_BODY=$(gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" --paginate --slurp \ + | jq -r 'add | [.[] | select(.user.login == "mintlify[bot]" and (.body | contains("mintlify-preview-comment")))] | max_by(.updated_at) | .body // empty') # Status emoji-prefixed token in the table row if echo "$COMMENT_BODY" | grep -q '🔴 Failed'; then @@ -89,7 +92,7 @@ jobs: exit 1 fi - URL=$(echo "$COMMENT_BODY" | grep -oE 'https://[a-z0-9-]+\.(mintlify\.(app|site)|mintlifysite\.com)' | head -1 || true) + URL=$(echo "$COMMENT_BODY" | grep -oE "$PREVIEW_URL_RE" | head -1 || true) if echo "$COMMENT_BODY" | grep -q '🟢 Ready' && [ -n "$URL" ]; then echo "Mintlify Deployment $DEPLOY — preview: $URL" @@ -114,6 +117,16 @@ jobs: pending) ;; success) + # The deployment's summary names the preview it built, so the + # URL doesn't depend on which preview comment Mintlify updates. + URL=$(gh api "repos/${{ github.repository }}/commits/$HEAD_SHA/check-runs" --paginate \ + --jq '.check_runs[] | select(.name == "Mintlify Deployment" and .conclusion == "success") | .output.summary // empty' \ + | grep -oE "$PREVIEW_URL_RE" | head -1 || true) + if [ -n "$URL" ]; then + echo "Mintlify Deployment $DEPLOY — preview: $URL" + echo "url=$URL" >> "$GITHUB_OUTPUT" + exit 0 + fi read_preview ;; none|skipped) From 8ae32662577511e1d94e2ee6d3fe44a97f2e99f4 Mon Sep 17 00:00:00 2001 From: Hannes Lenke Date: Sat, 7 Nov 2026 20:34:48 -0500 Subject: [PATCH 2/2] ci(preview-checks): check API pages against the PR head, not the merge ref Mintlify builds the preview from the PR head, but the API page check read docs.json from the merge commit. A branch older than a generated API page on main then failed with 404s for pages it never had (the 5 usage pages on #449, #475, #506, #511). Read the expected pages from a worktree of the head commit. The script still runs from the merge checkout, since older heads don't have it. Co-Authored-By: Claude Opus 5.5 --- .github/scripts/check-api-preview.mjs | 3 ++- .github/workflows/preview-checks.yml | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/scripts/check-api-preview.mjs b/.github/scripts/check-api-preview.mjs index fdd828b8..85132937 100644 --- a/.github/scripts/check-api-preview.mjs +++ b/.github/scripts/check-api-preview.mjs @@ -1,7 +1,8 @@ import { getNavigationPages } from './api-navigation.mjs'; const base = new URL(process.argv[2].replace(/\/?$/, '/')); -const pages = getNavigationPages(process.cwd()).filter((page) => page.operation); +// Optional second argument: the docs root to read the navigation from. +const pages = getNavigationPages(process.argv[3] ?? process.cwd()).filter((page) => page.operation); const failures = []; // Mintlify previews occasionally answer a single request with a 500. diff --git a/.github/workflows/preview-checks.yml b/.github/workflows/preview-checks.yml index 48d72ebc..7c95a4fa 100644 --- a/.github/workflows/preview-checks.yml +++ b/.github/workflows/preview-checks.yml @@ -167,7 +167,12 @@ jobs: if: steps.preview.outputs.url != '' env: DOCS_PREVIEW_URL: ${{ steps.preview.outputs.url }} - run: node .github/scripts/check-api-preview.mjs "$DOCS_PREVIEW_URL" + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + # Mintlify builds the PR head, not the merge commit checked out above, + # so read the expected pages from the head's docs.json. + git worktree add --detach "$RUNNER_TEMP/pr-head" "$HEAD_SHA" + node .github/scripts/check-api-preview.mjs "$DOCS_PREVIEW_URL" "$RUNNER_TEMP/pr-head" - name: Install dependencies if: steps.preview.outputs.url != ''