Skip to content

Commit 38720ee

Browse files
jmelahmanclaude
andcommitted
ci: harden the local-preview deploy workflow
Replace the `A && B || C` public copy with an if block, so a missing directory stays optional but a failed copy fails the job. actionlint flagged the old form (SC2015). Paginate the PR comment lookup: on a long PR the marker can sit past the first page, which posts a duplicate comment. Add a per-branch concurrency group so two commits deploying together cannot finish out of order and leave a stale preview URL. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent c464fa0 commit 38720ee

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

.github/workflows/local-preview.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ on:
2828
# then still runs the chosen branch's copy.
2929
workflow_dispatch:
3030

31+
# One deploy per branch at a time. Without this, two commits deploying
32+
# together can finish out of order and leave the PR comment on the older
33+
# commit's URL. Cancelling the older run also frees the server sooner.
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.ref }}
36+
cancel-in-progress: true
37+
3138
permissions:
3239
contents: read
3340

@@ -100,7 +107,9 @@ jobs:
100107
bun run --filter './lib/opal' build
101108
bun run build:fast
102109
cp -r .next/static .next/standalone/.next/static
103-
[ -d public ] && cp -r public .next/standalone/public || true
110+
if [ -d public ]; then
111+
cp -r public .next/standalone/public
112+
fi
104113
105114
# The published tree becomes the process's working directory and the
106115
# manifest runs `node .next/standalone/server.js` in it, so the upload
@@ -146,7 +155,8 @@ jobs:
146155
147156
Sign in with GitHub${PREVIEW_SSO_ORG:+ as an \`$PREVIEW_SSO_ORG\` member} to view it."
148157
149-
EXISTING_COMMENT_ID=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
158+
# --paginate: on a long PR the marker can sit past the first page.
159+
EXISTING_COMMENT_ID=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
150160
--jq ".[] | select(.body | startswith(\"$COMMENT_MARKER\")) | .id" | head -1)
151161
152162
if [ -n "$EXISTING_COMMENT_ID" ]; then

0 commit comments

Comments
 (0)