|
1 | | -name: CI |
| 1 | +name: CI / Deploy |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
7 | 7 | branches: [main] |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - test: |
| 10 | + check: |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 | permissions: |
13 | 13 | id-token: write |
14 | 14 | contents: read |
15 | 15 | steps: |
16 | 16 | - uses: actions/checkout@v4 |
17 | | - |
| 17 | + |
18 | 18 | - name: Setup Node.js |
19 | 19 | uses: actions/setup-node@v4 |
20 | 20 | with: |
21 | 21 | node-version: '20' |
22 | | - |
| 22 | + |
23 | 23 | - name: Install dependencies |
24 | 24 | run: npm install --legacy-peer-deps |
25 | | - |
| 25 | + |
26 | 26 | - name: Type check |
27 | 27 | run: npm run check |
28 | 28 |
|
29 | 29 | - name: Run tests with coverage |
30 | 30 | run: npm run test:coverage |
31 | | - |
| 31 | + |
32 | 32 | - name: Upload coverage to Codecov |
33 | 33 | uses: codecov/codecov-action@v4 |
34 | 34 | with: |
|
37 | 37 | flags: unittests |
38 | 38 | name: openboot-web-coverage |
39 | 39 | fail_ci_if_error: false |
40 | | - |
| 40 | + |
| 41 | + - name: Build |
| 42 | + run: npm run build |
| 43 | + |
| 44 | + deploy: |
| 45 | + needs: check |
| 46 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 47 | + runs-on: ubuntu-latest |
| 48 | + permissions: |
| 49 | + id-token: write |
| 50 | + contents: read |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Setup Node.js |
| 55 | + uses: actions/setup-node@v4 |
| 56 | + with: |
| 57 | + node-version: '20' |
| 58 | + |
| 59 | + - name: Install dependencies |
| 60 | + run: npm install --legacy-peer-deps |
| 61 | + |
41 | 62 | - name: Build |
42 | 63 | run: npm run build |
| 64 | + |
| 65 | + - name: Run D1 Migrations |
| 66 | + env: |
| 67 | + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 68 | + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 69 | + run: npx wrangler d1 migrations apply openboot --remote |
| 70 | + |
| 71 | + - name: Deploy |
| 72 | + uses: cloudflare/wrangler-action@v3 |
| 73 | + with: |
| 74 | + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 75 | + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 76 | + |
| 77 | + - name: Health Check |
| 78 | + run: | |
| 79 | + echo "Waiting 10 seconds for deployment to propagate..." |
| 80 | + sleep 10 |
| 81 | +
|
| 82 | + echo "Running health check..." |
| 83 | + HEALTH_RESPONSE=$(curl -s https://openboot.dev/api/health) |
| 84 | + echo "Health check response: $HEALTH_RESPONSE" |
| 85 | +
|
| 86 | + STATUS=$(echo $HEALTH_RESPONSE | jq -r '.status') |
| 87 | + if [ "$STATUS" != "healthy" ]; then |
| 88 | + echo "Health check failed! Status: $STATUS" |
| 89 | + echo "Full response: $HEALTH_RESPONSE" |
| 90 | + exit 1 |
| 91 | + fi |
| 92 | +
|
| 93 | + echo "Health check passed!" |
| 94 | + echo "API: $(echo $HEALTH_RESPONSE | jq -r '.checks.api')" |
| 95 | + echo "Database: $(echo $HEALTH_RESPONSE | jq -r '.checks.database')" |
| 96 | + echo "Version: $(echo $HEALTH_RESPONSE | jq -r '.version')" |
0 commit comments