|
| 1 | +name: Deploy to Production |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [prod] |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + runs-on: ubuntu-24.04 |
| 10 | + |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v5 |
| 14 | + |
| 15 | + - name: Enable corepack |
| 16 | + run: corepack enable |
| 17 | + |
| 18 | + - name: Setup Node.js |
| 19 | + uses: actions/setup-node@v5 |
| 20 | + with: |
| 21 | + node-version-file: ".node-version" |
| 22 | + cache: "pnpm" |
| 23 | + cache-dependency-path: "pnpm-lock.yaml" |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: pnpm install --frozen-lockfile |
| 27 | + |
| 28 | + - name: Run tests |
| 29 | + run: pnpm test:run |
| 30 | + |
| 31 | + - name: Run linter (without build artifacts) |
| 32 | + run: rm -rf dist && rm -f hono/static/*.js hono/static/*.js.map && pnpm lint |
| 33 | + |
| 34 | + - name: Run build |
| 35 | + run: pnpm build |
| 36 | + |
| 37 | + e2e: |
| 38 | + runs-on: ubuntu-24.04 |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v5 |
| 43 | + |
| 44 | + - name: Enable corepack |
| 45 | + run: corepack enable |
| 46 | + |
| 47 | + - name: Setup Node.js |
| 48 | + uses: actions/setup-node@v5 |
| 49 | + with: |
| 50 | + node-version-file: ".node-version" |
| 51 | + cache: "pnpm" |
| 52 | + cache-dependency-path: "pnpm-lock.yaml" |
| 53 | + |
| 54 | + - name: Install dependencies |
| 55 | + run: pnpm install --frozen-lockfile |
| 56 | + |
| 57 | + - name: Install Playwright Browsers |
| 58 | + run: pnpm exec playwright install --with-deps chromium |
| 59 | + |
| 60 | + - name: Build JavaScript files |
| 61 | + run: pnpm build |
| 62 | + |
| 63 | + - name: Run database migrations |
| 64 | + run: pnpm db:migrate |
| 65 | + |
| 66 | + - name: Seed database |
| 67 | + run: pnpm db:seed |
| 68 | + |
| 69 | + - name: Run Playwright tests |
| 70 | + env: |
| 71 | + SESSION_SECRET: ${{ secrets.SESSION_SECRET }} |
| 72 | + E2E_GMAIL_ACCOUNT: ${{ secrets.E2E_GMAIL_ACCOUNT }} |
| 73 | + E2E_GMAIL_PASSWORD: ${{ secrets.E2E_GMAIL_PASSWORD }} |
| 74 | + run: pnpm test:e2e |
| 75 | + |
| 76 | + - name: Upload test artifacts |
| 77 | + uses: actions/upload-artifact@v5 |
| 78 | + if: failure() |
| 79 | + with: |
| 80 | + name: playwright-report |
| 81 | + path: playwright-report/ |
| 82 | + retention-days: 30 |
| 83 | + |
| 84 | + deploy: |
| 85 | + needs: [test, e2e] |
| 86 | + runs-on: ubuntu-24.04 |
| 87 | + |
| 88 | + steps: |
| 89 | + - name: Checkout code |
| 90 | + uses: actions/checkout@v5 |
| 91 | + |
| 92 | + - name: Enable corepack |
| 93 | + run: corepack enable |
| 94 | + |
| 95 | + - name: Setup Node.js |
| 96 | + uses: actions/setup-node@v5 |
| 97 | + with: |
| 98 | + node-version-file: ".node-version" |
| 99 | + cache: "pnpm" |
| 100 | + cache-dependency-path: "pnpm-lock.yaml" |
| 101 | + |
| 102 | + - name: Install dependencies |
| 103 | + run: pnpm install --frozen-lockfile |
| 104 | + |
| 105 | + - name: Apply D1 database migrations |
| 106 | + run: pnpm db:migrate:prod |
| 107 | + env: |
| 108 | + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 109 | + |
| 110 | + - name: Deploy to Cloudflare Workers |
| 111 | + run: pnpm run deploy |
| 112 | + env: |
| 113 | + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
0 commit comments