Skip to content

Commit 5ca5103

Browse files
ericyangpanclaude
andcommitted
fix(ci): improve preview alias generation and cloudflare deployment
- Sanitize branch slug before truncation, then clean trailing hyphens - Add --env="" flag to Cloudflare Pages upload command Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 50bbfb3 commit 5ca5103

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

.github/workflows/deploy-preview.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ jobs:
7070
CONTEXT_LABEL="PR #${{ github.event.pull_request.number }}"
7171
else
7272
RAW_BRANCH="${{ github.ref_name }}"
73-
SLUG="$(echo "$RAW_BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's#[^a-z0-9]+#-#g; s#(^-+|-+$)##g' | cut -c1-40)"
73+
# First sanitize and truncate, then clean up any trailing hyphens from truncation
74+
SLUG="$(echo "$RAW_BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's#[^a-z0-9]+#-#g' | cut -c1-40 | sed -E 's#-+$##g; s#(^-+)##g')"
7475
if [[ -z "$SLUG" ]]; then
7576
SLUG="branch"
7677
fi
@@ -116,7 +117,7 @@ jobs:
116117
with:
117118
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
118119
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
119-
command: versions upload --preview-alias ${{ steps.preview_meta.outputs.preview_alias }}
120+
command: versions upload --preview-alias ${{ steps.preview_meta.outputs.preview_alias }} --env=""
120121

121122
- name: Comment Preview URL
122123
if: github.event_name == 'pull_request'

0 commit comments

Comments
 (0)