Merge pull request #29 from zxcloli666/claude/fervent-turing-3EFUZ #50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to Cloudflare Workers | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref || github.ref }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Run ESLint | |
| run: pnpm run lint | |
| - name: Run type check | |
| run: pnpm run type-check | |
| - name: Format code | |
| run: pnpm exec prettier --write "src/**/*.ts" | |
| - name: Commit and push formatting changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git diff --staged --quiet || git commit -m "style: auto-format with prettier [skip ci]" | |
| git push | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref || github.ref }} | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Replace ROUTES_CONFIG in wrangler.toml | |
| env: | |
| ROUTES_CONFIG: ${{ vars.ROUTES_CONFIG }} | |
| run: | | |
| # Remove existing [vars] section and everything after it | |
| sed -i '/^\[vars\]/,$d' wrangler.toml | |
| # Add new [vars] section with GitHub Variable | |
| cat >> wrangler.toml << EOF | |
| [vars] | |
| ROUTES_CONFIG = '''${ROUTES_CONFIG}''' | |
| EOF | |
| - name: Deploy to Cloudflare Workers | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |