cloudflare.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. name: Build and Deploy to Cloudflare
  2. on:
  3. push:
  4. branches: [ master ]
  5. jobs:
  6. build:
  7. runs-on: ubuntu-latest
  8. name: Build Application
  9. permissions:
  10. contents: read
  11. steps:
  12. - name: Checkout
  13. uses: actions/checkout@v5
  14. with:
  15. fetch-depth: 0
  16. - name: Setup Node
  17. uses: actions/setup-node@v4
  18. with:
  19. node-version: 20
  20. - name: Install dependencies
  21. run: npm install --force
  22. - name: Build application
  23. run: npm run build:preview
  24. - name: Upload build artifacts
  25. uses: actions/upload-artifact@v4
  26. with:
  27. name: build-files
  28. path: dist/
  29. retention-days: 1
  30. deploy:
  31. runs-on: ubuntu-latest
  32. name: Deploy to Cloudflare
  33. needs: build
  34. permissions:
  35. contents: read
  36. deployments: write
  37. steps:
  38. - name: Checkout (for config files)
  39. uses: actions/checkout@v5
  40. with:
  41. sparse-checkout: |
  42. wrangler.jsonc
  43. sparse-checkout-cone-mode: false
  44. - name: Download build artifacts
  45. uses: actions/download-artifact@v4
  46. with:
  47. name: build-files
  48. path: dist/
  49. - name: Deploy (Workers + Static Assets)
  50. uses: cloudflare/wrangler-action@v3.14.1
  51. with:
  52. apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
  53. accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
  54. command: deploy --config wrangler.jsonc
  55. gitHubToken: ${{ secrets.GITHUB_TOKEN }}