Skip to content

Commit a8ab7a5

Browse files
Theodor N. EngøyTheodor N. Engøy
authored andcommitted
ci: retry pkg-pr-new publish on transient 5xx
1 parent 65bbcea commit a8ab7a5

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

.github/workflows/publish.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,33 @@ jobs:
3838
run: pnpm run build:all
3939

4040
- name: Publish preview packages
41-
run:
42-
pnpm dlx pkg-pr-new publish --packageManager=npm --pnpm './packages/server' './packages/client'
43-
'./packages/middleware/express' './packages/middleware/hono' './packages/middleware/node'
41+
shell: bash
42+
run: |
43+
set -euo pipefail
44+
45+
# pkg.pr.new can occasionally return transient 5xx/Cloudflare errors.
46+
# Retry a few times to reduce CI flake without masking real failures.
47+
for attempt in 1 2 3; do
48+
tmp="$(mktemp)"
49+
if pnpm dlx pkg-pr-new publish --packageManager=npm --pnpm \
50+
'./packages/server' \
51+
'./packages/client' \
52+
'./packages/middleware/express' \
53+
'./packages/middleware/hono' \
54+
'./packages/middleware/node' \
55+
2>&1 | tee "$tmp"; then
56+
exit 0
57+
fi
58+
59+
if grep -Eq 'Check failed \\(5[0-9]{2}\\)|Cloudflare|Worker threw exception' "$tmp"; then
60+
echo "pkg-pr-new publish failed with a transient-looking error (attempt $attempt/3). Retrying..." >&2
61+
sleep "$((attempt * 10))"
62+
continue
63+
fi
64+
65+
echo "pkg-pr-new publish failed with a non-transient error; not retrying." >&2
66+
exit 1
67+
done
68+
69+
echo "pkg-pr-new publish failed after retries." >&2
70+
exit 1

0 commit comments

Comments
 (0)