Skip to content

Commit 64c8127

Browse files
committed
ci: replace wrangler-action with direct wrangler CLI and deploy script
Use the package.json wrangler CLI instead of cloudflare/wrangler-action. The deploy job now checks out the repo, installs deps, then runs pnpm wrangler pages deploy directly. Post-deploy GitHub integration (PR comment, deployment record, step summary) is handled by .github/scripts/cloudflare-deploy.sh.
1 parent bc2085e commit 64c8127

1 file changed

Lines changed: 36 additions & 13 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ permissions:
1111
contents: read
1212
pages: write
1313
id-token: write
14+
deployments: write
15+
pull-requests: write
1416

1517
jobs:
1618
build:
@@ -46,8 +48,21 @@ jobs:
4648
runs-on: ubuntu-latest
4749
environment:
4850
name: cloudflare-pages
49-
url: ${{ steps.deploy.outputs.deployment-url }}
5051
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v6
54+
55+
- name: Set up Node.js
56+
uses: actions/setup-node@v6
57+
with:
58+
node-version-file: .tool-versions
59+
60+
- name: Enable corepack
61+
run: corepack enable
62+
63+
- name: Install dependencies
64+
run: pnpm install --frozen-lockfile
65+
5166
- name: Download dist artifact
5267
uses: actions/download-artifact@v8
5368
with:
@@ -56,19 +71,27 @@ jobs:
5671

5772
- name: Deploy to Cloudflare Pages
5873
id: deploy
59-
uses: cloudflare/wrangler-action@v3
60-
with:
61-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
62-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
63-
command: pages deploy dist --project-name=chinmina
74+
env:
75+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
76+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
77+
WRANGLER_OUTPUT_FILE_DIRECTORY: .wrangler-output
78+
run: pnpm wrangler pages deploy dist --project-name=chinmina
6479

65-
- name: Add deployment summary
66-
run: |
67-
echo "### Cloudflare Pages Deployment" >> $GITHUB_STEP_SUMMARY
68-
echo "URL: ${{ steps.deploy.outputs.deployment-url }}" >> $GITHUB_STEP_SUMMARY
69-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
70-
echo "Preview: ${{ steps.deploy.outputs.deployment-url }}" >> $GITHUB_STEP_SUMMARY
71-
fi
80+
- name: Post PR comment
81+
if: github.event_name == 'pull_request'
82+
env:
83+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
WRANGLER_OUTPUT_FILE_DIRECTORY: .wrangler-output
85+
PR_NUMBER: ${{ github.event.pull_request.number }}
86+
run: .github/scripts/cloudflare-deploy.sh comment
87+
88+
- name: Create GitHub deployment
89+
if: always() && steps.deploy.outcome == 'success'
90+
env:
91+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
WRANGLER_OUTPUT_FILE_DIRECTORY: .wrangler-output
93+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
94+
run: .github/scripts/cloudflare-deploy.sh deployment
7295

7396
deploy:
7497
needs: build

0 commit comments

Comments
 (0)