Skip to content

Commit c618acc

Browse files
committed
[Docs Site] Post Workers preview URL on PRs
1 parent 528130f commit c618acc

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

.github/workflows/publish-preview.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,25 @@ jobs:
3131
name: Build
3232
env:
3333
NODE_OPTIONS: --max-old-space-size=4096
34-
- run: npx wrangler pages deploy --project-name cloudflare-docs dist
35-
name: Deploy to Cloudflare Pages
36-
env:
37-
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
38-
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
3934
- run: npx wrangler versions upload -c ./wrangler-workers.toml
4035
name: Deploy to Cloudflare Workers
4136
env:
4237
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
38+
WRANGLER_OUTPUT_FILE_PATH: wrangler-logs.json
39+
- name: Post preview URL on PR
40+
env:
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
PR=$(gh pr list --head ${{ github.ref_name }} --limit 1 --json number --jq '.[].number')
44+
45+
if [ -z "$PR" ]; then
46+
URL=$(cat wrangler-logs.json | jq 'select(.type=="version-upload") | .preview_url')
47+
48+
if [ -z "$URL" ]; then
49+
BODY="**Preview URL:** $URL"
50+
gh pr comment "$PR" --repo ${{ github.repository }} --edit-last --body-file -
51+
fi
52+
fi
4353
- uses: actions/cache/save@v4
4454
if: always()
4555
with:

0 commit comments

Comments
 (0)