Update workflow and add gitignore files #2
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: Test & Deploy | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: test-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # ------------------------- | |
| # Server: test & build | |
| # ------------------------- | |
| test-server: | |
| name: Test Server | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| env: | |
| CI: true | |
| ADMIN_SECRET: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24.3.0 | |
| - name: Match npm version (11.4.2) & verify | |
| run: | | |
| npm install -g npm@11.4.2 | |
| node -v | |
| npm -v | |
| - name: Install, lint, test, build | |
| working-directory: server | |
| run: | | |
| npm ci | |
| npm run lint | |
| npm test | |
| npm run build | |
| - name: Upload server build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: server-build | |
| path: server/dist | |
| # ------------------------- | |
| # Server: deploy (only after server tests pass, only on main) | |
| # ------------------------- | |
| deploy-server: | |
| name: Deploy Server (traceoffapi) | |
| runs-on: ubuntu-latest | |
| needs: test-server | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| # Create .vercel/project.json at runtime without committing it | |
| - name: Vercel pull (production) | |
| working-directory: server | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_API_ID }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} # optional for Personal accounts | |
| run: npx vercel pull --yes --environment=production | |
| # Deploy using project/env from the pull step | |
| - name: Deploy to Vercel (prod) | |
| working-directory: server | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_API_ID }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} # optional | |
| run: npx vercel deploy --prod --yes | |
| # ------------------------- | |
| # Mobile: test Android build | |
| # ------------------------- | |
| test-mobile: | |
| name: Test Mobile App | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 40 | |
| env: | |
| CI: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: 3.35.3 | |
| channel: stable | |
| cache: true | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| cache: gradle | |
| - uses: android-actions/setup-android@v3 | |
| - run: flutter --version | |
| - name: Setup environment file | |
| run: cp server/.env.example mobile/.env | |
| - name: Test mobile app | |
| working-directory: mobile | |
| run: | | |
| flutter pub get | |
| flutter analyze | |
| flutter test | |
| flutter build apk --release | |
| - name: Upload APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-release-apk | |
| path: mobile/build/app/outputs/flutter-apk/app-release.apk | |
| # ------------------------- | |
| # Web: build & deploy Flutter web (only after mobile tests pass, only on main) | |
| # ------------------------- | |
| deploy-web: | |
| name: Deploy Flutter Web (traceoff) | |
| runs-on: ubuntu-latest | |
| needs: test-mobile | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: 3.35.3 | |
| channel: stable | |
| cache: true | |
| - name: Build Flutter Web | |
| working-directory: mobile | |
| run: | | |
| flutter pub get | |
| flutter build web --release | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| # Link project for this directory (we deploy from build output dir) | |
| - name: Vercel pull (production) | |
| working-directory: mobile/build/web | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_WEB_ID }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} # optional | |
| run: npx vercel pull --yes --environment=production | |
| - name: Deploy to Vercel (prod) | |
| working-directory: mobile/build/web | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_WEB_ID }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} # optional | |
| run: npx vercel deploy --prod --yes |