chore: update build scripts and add Cloudflare deployment workflow

3.x
tangjinzhou 2025-09-19 14:53:24 +08:00
parent 646de93ed5
commit e1d2133118
3 changed files with 79 additions and 3 deletions

63
.github/workflows/cloudflare.yml vendored Normal file
View File

@ -0,0 +1,63 @@
name: Build and Deploy to Cloudflare
on:
push:
branches: [ 3.x ]
jobs:
build:
runs-on: ubuntu-latest
name: Build Application
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install --force
- name: Build application
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-files
path: site/dist/
retention-days: 1
deploy:
runs-on: ubuntu-latest
name: Deploy to Cloudflare
needs: build
permissions:
contents: read
deployments: write
steps:
- name: Checkout (for config files)
uses: actions/checkout@v5
with:
sparse-checkout: |
wrangler.jsonc
sparse-checkout-cone-mode: false
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-files
path: site/dist/
- name: Deploy (Workers + Static Assets)
uses: cloudflare/wrangler-action@v3.14.1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --config wrangler.jsonc
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

View File

@ -33,7 +33,7 @@
"precompile": "npm run version",
"pretest": "npm run version",
"predist": "npm run version",
"presite": "npm run version",
"prebuild": "npm run version",
"dev": "npm run predev && npm run routes && vite serve site",
"test": "cross-env NODE_ENV=test jest --config .jest.js",
"compile": "node antd-tools/cli/run.js compile",
@ -56,8 +56,7 @@
"routes": "node site/scripts/genrateRoutes.js",
"tsc": "tsc --noEmit",
"vue-tsc": "vue-tsc --noEmit",
"site": "npm run routes && ./node_modules/vite/bin/vite.js build site --base=https://3x.antdv.com/",
"pub:site": "npm run site && node site/scripts/pushToOSS.js",
"build": "npm run routes && ./node_modules/vite/bin/vite.js build site --base=/",
"prepare": "husky install",
"version": "node ./scripts/generate-version",
"sort-api": "node antd-tools/cli/run.js sort-api-table"

14
wrangler.jsonc Normal file
View File

@ -0,0 +1,14 @@
{
"name": "antdv-v3",
"compatibility_date": "2025-09-19",
"assets": {
"directory": "./site/dist",
"not_found_handling": "single-page-application"
},
"routes": [
{
"pattern": "3x.antdv.com/*",
"zone_name": "antdv.com"
}
]
}