diff --git a/.github/workflows/cloudflare.yml b/.github/workflows/cloudflare.yml new file mode 100644 index 000000000..5ea5b560f --- /dev/null +++ b/.github/workflows/cloudflare.yml @@ -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 }} diff --git a/package.json b/package.json index 987591e74..ff926e8c1 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 000000000..8d86a3f10 --- /dev/null +++ b/wrangler.jsonc @@ -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" + } + ] +}