workspace-quarto-site: make preview-comment read genuinely best-effort - #92
Closed
gas2own wants to merge 1 commit into
Closed
workspace-quarto-site: make preview-comment read genuinely best-effort#92gas2own wants to merge 1 commit into
gas2own wants to merge 1 commit into
Conversation
The deploy step runs under `set -e`. The PR preview-comment block is meant
to be best-effort ("a comment hiccup shouldn't fail an otherwise-successful
publish"), and its two write calls are guarded with `|| echo ::warning`.
But the read that seeds `existing` — an unguarded command substitution —
was not. When `gh api` gets a transient HTML 5xx error page instead of JSON
(observed as `invalid character '<' looking for beginning of value`), the
substitution returns non-zero and `set -e` aborts the whole deploy job,
even though gh-pages was already published successfully.
Guard the read the same way: swallow the failure, emit a warning, and
continue with an empty `existing` (falls through to the create branch,
itself already guarded). Now a flaky GitHub API only costs the comment,
not the deploy status.
gas2own
added a commit
that referenced
this pull request
Jul 16, 2026
…ct URL on private repos) Two latent bugs in the reusable Quarto deploy workflow made a freshly scaffolded repo's first PR look broken (red deploy check, no/wrong preview link) even when the site published fine: 1. The preview-comment gh api read was unguarded under set -e; a transient 5xx HTML body breaks --jq and abORTS the deploy after publish. Now the block runs under set +e and closes on a guaranteed-success command. 2. The preview URL was hardcoded to <owner>.github.io/<repo>, dead on private/internal repos that serve from an obfuscated *.pages.github.io domain. Now resolved from the Pages API with fallback; deploy job and scaffold docs.yml template grant pages: read. Supersedes #91, #92, #93. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
|
Superseded by #94, which consolidates this preview-comment robustness fix (and adds the private-repo preview-URL fix) into a single PR. Closing to keep the review surface to one PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The reusable Quarto docs deploy step runs under
bash -e. Its PR preview-comment block is explicitly meant to be best-effort — the comment even says "a comment hiccup shouldn't fail an otherwise-successful publish" — and its two write calls (PATCH/POST) are guarded with|| echo "::warning::…".But the read that seeds
existingwas an unguarded command substitution:existing=$(gh api "repos/.../issues/$PR_NUMBER/comments" --jq '…')When
gh apigets a transient HTML 5xx error page instead of JSON, it exits non-zero and printsinvalid character '<' looking for beginning of value. Underset -e, that failed substitution aborts the whole deploy job with exit 1 — even though gh-pages was already published successfully.Observed live on a freshly-scaffolded workspace repo during a brief GitHub API blip: the site deployed fine (
gh-pages already up to date), then the job went red on the comment read.Fix
Guard the read the same way the writes are guarded: redirect stderr, swallow the non-zero exit, emit a
::warning::, and continue with an emptyexisting(which falls through to the create branch, itself already guarded). Now a flaky GitHub API only costs the preview comment, not the deploy status.🤖 Generated with Claude Code