Skip to content

workspace skill: make PR preview-comment step un-failable so a transient API error can't red the deploy#93

Closed
gas2own wants to merge 1 commit into
mainfrom
fix-preview-comment-cannot-fail-deploy
Closed

workspace skill: make PR preview-comment step un-failable so a transient API error can't red the deploy#93
gas2own wants to merge 1 commit into
mainfrom
fix-preview-comment-cannot-fail-deploy

Conversation

@gas2own

@gas2own gas2own commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

What

In the workspace-skill shared workflow .github/workflows/workspace-quarto-site.yml, the deploy job's preview-comment block now runs with set +e and guards its read call, so a transient GitHub API error during comment posting can no longer fail an otherwise-successful publish.

Why

The block is documented as "Best-effort — a comment hiccup shouldn't fail an otherwise-successful publish", but it didn't behave that way. The first call — existing=$(gh api … --jq …) — had no || guard and ran under the step's default set -e. When the GitHub API returns a 5xx, gh api emits an HTML error page; --jq then fails with invalid character '<' looking for beginning of value, the command substitution exits non-zero, and under set -e a bare assignment aborts the whole step.

Net effect: the site was published to gh-pages, but the docs / deploy check went red purely because the follow-up comment fetch hit a transient API blip.

This reproduced on a freshly-scaffolded workspace repo during a brief GitHub API outage — exactly the "onboarding should be bulletproof" case. Log excerpt:

```
gh-pages already up to date
invalid character '<' looking for beginning of value
##[error]Process completed with exit code 1.
```

Confirmed the set -e semantics: bash -e -c 'x=\$(bash -c "exit 1"); echo reached' never prints reached.

Change

  • Wrap the whole PR preview-comment block in set +e / set -e.
  • Add a || echo "::warning::…" guard to the read call, matching the existing guards on the PATCH/POST writes.

Previews stay attached to the PR via the same 📄 Preview: comment + /pr-preview/pr-<N>/ URL; only robustness changes. YAML validated with yaml.safe_load.

🤖 Generated with Claude Code

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>
…'t red the deploy

The deploy job publishes the site to gh-pages and then posts/updates a
best-effort "📄 Preview:" comment on the PR. That comment block ran under the
step's default `set -e`, and the first call — `existing=$(gh api ... --jq ...)`
— had no guard. When the GitHub API returns a 5xx, `gh api` emits an HTML error
page that breaks `--jq` parsing ("invalid character '<'"), the command
substitution exits non-zero, and under `set -e` a bare assignment aborts the
whole step. Result: an otherwise-successful publish (gh-pages already updated)
shows a red `docs / deploy` check.

This reproduced on a freshly-scaffolded workspace repo during a brief GitHub API
outage, contradicting the block's own "Best-effort — a comment hiccup shouldn't
fail an otherwise-successful publish" comment.

Fix: disable errexit for the whole comment block and guard the read the same
way the writes already are, so no comment-time API hiccup can fail the deploy.
Previews stay attached to the PR via the comment; robustness is the only change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gas2own
gas2own force-pushed the fix-preview-comment-cannot-fail-deploy branch from d2b1280 to 4de2c9a Compare July 16, 2026 23:25
@gas2own

gas2own commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #94, which is a strict superset of this change (un-failable preview-comment block + correct preview URL on private repos). Closing to consolidate review onto #94.

@gas2own gas2own closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant