|
| 1 | +name: Deploy to Cloudflare Pages |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + lint: |
| 8 | + name: Lint |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v5 |
| 14 | + |
| 15 | + - name: Setup Node.js |
| 16 | + uses: actions/setup-node@v6 |
| 17 | + with: |
| 18 | + node-version-file: '.nvmrc' |
| 19 | + cache: 'npm' |
| 20 | + |
| 21 | + - name: Install dependencies |
| 22 | + run: npm ci |
| 23 | + |
| 24 | + - name: Run linter |
| 25 | + run: npm run lint |
| 26 | + |
| 27 | + test-unit: |
| 28 | + name: Unit Tests |
| 29 | + runs-on: ubuntu-latest |
| 30 | + needs: lint |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@v5 |
| 35 | + |
| 36 | + - name: Setup Node.js |
| 37 | + uses: actions/setup-node@v6 |
| 38 | + with: |
| 39 | + node-version-file: '.nvmrc' |
| 40 | + cache: 'npm' |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + run: npm ci |
| 44 | + |
| 45 | + - name: Run unit tests |
| 46 | + run: npm run test:unit |
| 47 | + |
| 48 | + - name: Upload coverage reports |
| 49 | + if: always() |
| 50 | + uses: actions/upload-artifact@v4 |
| 51 | + with: |
| 52 | + name: coverage-report |
| 53 | + path: coverage/ |
| 54 | + if-no-files-found: ignore |
| 55 | + retention-days: 7 |
| 56 | + |
| 57 | + deploy: |
| 58 | + name: Deploy to Cloudflare Pages |
| 59 | + runs-on: ubuntu-latest |
| 60 | + needs: [lint, test-unit] |
| 61 | + environment: production |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Checkout code |
| 65 | + uses: actions/checkout@v5 |
| 66 | + |
| 67 | + - name: Setup Node.js |
| 68 | + uses: actions/setup-node@v6 |
| 69 | + with: |
| 70 | + node-version-file: '.nvmrc' |
| 71 | + cache: 'npm' |
| 72 | + |
| 73 | + - name: Install dependencies |
| 74 | + run: npm ci |
| 75 | + |
| 76 | + - name: Build project |
| 77 | + run: npm run build |
| 78 | + env: |
| 79 | + SUPABASE_URL: ${{ secrets.SUPABASE_URL }} |
| 80 | + SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} |
| 81 | + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }} |
| 82 | + |
| 83 | + - name: Deploy to Cloudflare Pages |
| 84 | + uses: cloudflare/wrangler-action@v3 |
| 85 | + with: |
| 86 | + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 87 | + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 88 | + command: pages deploy dist --project-name=10x-project |
| 89 | + |
0 commit comments