@@ -30,12 +30,15 @@ jobs:
3030 # Generates apps/sanity/extract.json and the site's types.gen.ts, both of
3131 # which are derived artifacts and therefore gitignored. Runs before
3232 # typecheck because the site imports the generated types.
33- - name : Typegen
33+ - name : Typegen (Sanity)
3434 run : pnpm typegen
3535 env :
3636 SANITY_STUDIO_PROJECT_ID : hfh83o0w
3737 SANITY_STUDIO_DATASET : production
3838
39+ - name : Typegen (Cloudflare)
40+ run : pnpm --filter @codingcatdev/site cf-typegen
41+
3942 - name : Lint (site)
4043 run : pnpm --filter @codingcatdev/site lint
4144
5457 SANITY_STUDIO_PROJECT_ID : hfh83o0w
5558 SANITY_STUDIO_DATASET : production
5659
60+ - name : Run E2E Tests
61+ run : pnpm --filter @codingcatdev/site test:e2e
62+
5763 # extract.json is committed and is the single source of truth for typegen.
5864 # The Typegen step above regenerates it; if that changed the file, the
5965 # commit is stale. This is what stopped three divergent copies before.
9197 SANITY_STUDIO_PROJECT_ID : hfh83o0w
9298 SANITY_STUDIO_DATASET : dev
9399
100+ - name : Generate Cloudflare Types
101+ run : pnpm --filter @codingcatdev/site cf-typegen
102+
94103 - name : Build site (preview)
95104 run : pnpm --filter @codingcatdev/site build
96105
@@ -99,7 +108,32 @@ jobs:
99108 run : |
100109 OUTPUT=$(pnpm --filter @codingcatdev/site exec wrangler versions upload --tag "pr-${{ github.event.pull_request.number }}" --message "PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}")
101110 echo "$OUTPUT"
111+
112+ PREVIEW_URL=$(echo "$OUTPUT" | grep -i "Version Preview URL:" | awk '{print $NF}' | head -n 1)
113+ VERSION_ID=$(echo "$OUTPUT" | grep -i "Worker Version ID:" | awk '{print $NF}' | head -n 1)
114+
115+ echo "preview_url=$PREVIEW_URL" >> $GITHUB_OUTPUT
116+ echo "version_id=$VERSION_ID" >> $GITHUB_OUTPUT
117+
118+ echo "### ⚡ Cloudflare Worker Preview Ready" >> $GITHUB_STEP_SUMMARY
119+ echo "" >> $GITHUB_STEP_SUMMARY
120+ echo "- **Preview URL**: [${PREVIEW_URL}](${PREVIEW_URL})" >> $GITHUB_STEP_SUMMARY
121+ echo "- **Version ID**: \`${VERSION_ID}\`" >> $GITHUB_STEP_SUMMARY
122+ echo "- **Target Worker**: \`codingcatdev-dev\`" >> $GITHUB_STEP_SUMMARY
123+
124+ if [ -n "$PREVIEW_URL" ]; then
125+ gh pr comment ${{ github.event.pull_request.number }} --body "### ⚡ Cloudflare Worker Preview Ready!
126+
127+ | Environment | URL |
128+ |---|---|
129+ | **PR Preview** | [${PREVIEW_URL}](${PREVIEW_URL}) |
130+ | **Dev Custom Domain** | [https://dev.codingcat.dev](https://dev.codingcat.dev) |
131+
132+ - **Worker Version ID**: \`${VERSION_ID}\`
133+ - **Protection**: Restricted to \`@codingcat.dev\` accounts via Cloudflare Zero Trust Access"
134+ fi
102135 env :
103136 CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
104137 CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID || 'c46bd0f3b9ed47b8692cca098030edbf' }}
138+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
105139
0 commit comments