name: Build and Deploy to Cloudflare on: push: branches: [ master ] 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:preview - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: build-files path: 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: 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 }}