ci: scope deploy typecheck to API, fix .dockerignore for remote builds #3
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 API | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'apps/api/**' | |
| - 'packages/contract/**' | |
| - 'packages/db/**' | |
| - 'packages/config/**' | |
| - 'fly.toml' | |
| - 'package.json' | |
| - 'bun.lock' | |
| workflow_dispatch: | |
| inputs: | |
| stage: | |
| description: Deployment stage | |
| required: true | |
| default: dev | |
| type: choice | |
| options: | |
| - dev | |
| - production | |
| concurrency: | |
| group: deploy-api-${{ inputs.stage || 'production' }} | |
| cancel-in-progress: false | |
| jobs: | |
| check: | |
| name: Typecheck & Test | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - run: bun install --frozen-lockfile | |
| - name: Build dependencies | |
| run: bun run --filter @sandchest/contract build && bun run --filter @sandchest/db build | |
| - name: Typecheck API | |
| run: bun run --filter @sandchest/api typecheck | |
| - name: Test API | |
| run: bun run --filter @sandchest/api test | |
| migrate: | |
| name: Run Database Migrations | |
| needs: check | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| environment: ${{ inputs.stage || 'production' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - run: bun install --frozen-lockfile | |
| - name: Run database migrations | |
| run: bun run db:migrate:run | |
| env: | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| deploy: | |
| name: Deploy to Fly.io | |
| needs: migrate | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| environment: ${{ inputs.stage || 'production' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: superfly/flyctl-actions/setup-flyctl@master | |
| - name: Deploy to Fly.io | |
| run: flyctl deploy --remote-only | |
| env: | |
| FLY_ACCESS_TOKEN: ${{ secrets.FLY_ACCESS_TOKEN }} | |
| - name: Verify deployment | |
| run: | | |
| sleep 10 | |
| flyctl status -a sandchest-api | |
| env: | |
| FLY_ACCESS_TOKEN: ${{ secrets.FLY_ACCESS_TOKEN }} |