Skip to content

Commit 630c3e8

Browse files
authored
Migrate to cloudflare/wrangler-action for deployment (#2549)
1 parent d43202f commit 630c3e8

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ jobs:
1313
permissions:
1414
contents: read
1515
deployments: write
16+
issues: write
17+
pull-requests: write
18+
checks: write
19+
statuses: write
1620
outputs:
17-
deployment_url: ${{ steps.cloudflare.outputs.url }}
21+
deployment_url: ${{ steps.deploy.outputs.url }}
1822
steps:
1923
- name: Checkout
2024
uses: actions/checkout@v4
@@ -52,27 +56,55 @@ jobs:
5256
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
5357
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
5458
SENTRY_DSN: ${{ vars.SENTRY_DSN }}
55-
- id: cloudflare
56-
name: Publish to Cloudflare Pages
57-
uses: cloudflare/pages-action@v1
59+
- id: deploy
60+
name: Publish to Cloudflare Pages (Preview)
61+
uses: cloudflare/wrangler-action@v3
5862
with:
5963
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
6064
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
61-
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
62-
directory: ./packages/gitbook/.vercel/output/static
63-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
6465
workingDirectory: ./
66+
wranglerVersion: '3.82.0'
67+
command: pages deploy ./packages/gitbook/.vercel/output/static --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch=${{ github.ref == 'refs/heads/main' && 'main' || format('pr{0}', github.event.pull_request.number) }}
6568
- name: Outputs
6669
run: |
67-
echo "ID: ${{ steps.cloudflare.outputs.id }}"
68-
echo "URL: ${{ steps.cloudflare.outputs.url }}"
69-
echo "Environment: ${{ steps.cloudflare.outputs.environment }}"
70-
echo "Alias: ${{ steps.cloudflare.outputs.alias }}"
70+
echo "URL: ${{ steps.deploy.outputs.url }}"
71+
echo "Alias URL: ${{ steps.deploy.outputs.deployment-alias-url }}"
7172
- name: Archive build output
7273
uses: actions/upload-artifact@v4
7374
with:
7475
name: build-output
7576
path: .vercel/
77+
# Until https://github.com/cloudflare/wrangler-action/issues/301 is done
78+
- name: Update Deployment Status to Success
79+
env:
80+
DEPLOYMENT_URL: ${{ steps.deploy.outputs.url }}
81+
run: |
82+
curl -X POST \
83+
-H "Authorization: token ${{ secrets.GH_PERSONAL_TOKEN }}" \
84+
-H "Accept: application/vnd.github.v3+json" \
85+
-d '{"state": "success", "target_url": "${{ steps.deploy.outputs.url }}", "description": "GitBook Preview URL", "context": "default"}' \
86+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }}
87+
88+
- name: Find GitHub Comment
89+
uses: peter-evans/find-comment@v3
90+
id: fc
91+
if: 1 && !startsWith(github.ref, 'refs/heads/main')
92+
with:
93+
issue-number: ${{ github.event.pull_request.number }}
94+
comment-author: 'github-actions[bot]'
95+
body-includes: GitBook Preview
96+
97+
- name: Create or update GitHub comment
98+
uses: peter-evans/create-or-update-comment@v4
99+
if: 1 && !startsWith(github.ref, 'refs/heads/main')
100+
with:
101+
comment-id: ${{ steps.fc.outputs.comment-id }}
102+
issue-number: ${{ github.event.pull_request.number }}
103+
body: |
104+
**GitBook Preview**
105+
Latest commit: [${{ steps.deploy.outputs.url }}](${{ steps.deploy.outputs.url }})
106+
PR: [${{ steps.deploy.outputs.alias }}](${{ steps.deploy.outputs.alias }})
107+
edit-mode: replace
76108
visual-testing:
77109
runs-on: ubuntu-latest
78110
name: Visual Testing

bun.lockb

5.05 KB
Binary file not shown.

packages/cache-do/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"devDependencies": {
2323
"typescript": "^5.5.3",
24-
"wrangler": "^3.78.7"
24+
"wrangler": "3.82.0"
2525
},
2626
"scripts": {
2727
"generate": "wrangler types --experimental-include-runtime",

0 commit comments

Comments
 (0)