diff --git a/.github/workflows/cloudflare.yml b/.github/workflows/cloudflare.yml new file mode 100644 index 000000000..b611f9c98 --- /dev/null +++ b/.github/workflows/cloudflare.yml @@ -0,0 +1,63 @@ +name: Build and Deploy to Cloudflare +on: + push: + branches: [ main ] + +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 2fb91f646..ddc790056 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "precompile": "npm run version & npm run collect-token-statistic & npm run token-meta", "pretest": "npm run version", "predist": "npm run version", - "presite": "npm run version & npm run routes & npm run collect-token-statistic & npm run token-meta", + "prebuild": "npm run version & npm run routes & npm run collect-token-statistic & npm run token-meta", "dev": "npm run routes && vite serve site", "fast-dev": "npm run routes && vite serve site", "test": "cross-env NODE_ENV=test jest --config .jest.js", @@ -60,7 +60,7 @@ "routes": "node site/scripts/genrateRoutes.js", "tsc": "tsc --noEmit", "vue-tsc": "vue-tsc --noEmit", - "site": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build site --base=https://next.antdv.com/", + "build": "node --max_old_space_size=8192 ./node_modules/vite/bin/vite.js build site --base=/", "pub:site": "npm run site && node site/scripts/pushToOSS.js", "prepare": "husky install", "version": "node ./scripts/generate-version", @@ -148,7 +148,6 @@ "babel-plugin-transform-require-context": "^0.1.1", "case-sensitive-paths-webpack-plugin": "^2.1.2", "chalk": "^4.1.1", - "cheerio": "^1.0.0-rc.2", "codecov": "^3.0.0", "codesandbox": "^2.2.3", "colorful": "^2.1.0", diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 000000000..1cba9cae6 --- /dev/null +++ b/wrangler.jsonc @@ -0,0 +1,8 @@ +{ + "name": "antdv-v4", + "compatibility_date": "2025-09-18", + "assets": { + "directory": "./site/dist", + "not_found_handling": "single-page-application" + } +}