Build iOS and Android Caches #319
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: Build iOS and Android Caches | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 6 * * *" # Daily at 6 AM UTC | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build-ios: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| name: Setup pnpm | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: ".nvmrc" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Generate Prisma client | |
| run: pnpm nx run tool:prisma-generate | |
| - name: Build iOS cache | |
| run: pnpm nx run tool:cli --target ios --verbose | |
| env: | |
| NODE_OPTIONS: "--max-old-space-size=4096" | |
| - name: Zip iOS database | |
| run: | | |
| cd apps/tool/assets/ios && zip ios-cache.zip cache.realm | |
| - name: Upload iOS cache | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ios-cache | |
| path: apps/tool/assets/ios/ios-cache.zip | |
| retention-days: 5 | |
| build-android: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| name: Setup pnpm | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: ".nvmrc" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Generate Prisma client | |
| run: pnpm nx run tool:prisma-generate | |
| - name: Build Android cache | |
| run: pnpm nx run tool:cli --target android --verbose | |
| env: | |
| NODE_OPTIONS: "--max-old-space-size=4096" | |
| DATABASE_URL: "file:${{ github.workspace }}/apps/tool/assets/android/cache.db?connection_limit=1&pool_timeout=60&query_timeout=60" | |
| - name: Zip Android database | |
| run: | | |
| cd apps/tool/assets/android && zip android-cache.zip cache.db | |
| - name: Upload Android cache | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-cache | |
| path: apps/tool/assets/android/android-cache.zip | |
| retention-days: 5 | |
| build-website: | |
| needs: [build-ios, build-android] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| name: Setup pnpm | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: ".nvmrc" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Download iOS artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ios-cache | |
| path: ./apps/website/public/ | |
| - name: Download Android artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: android-cache | |
| path: ./apps/website/public/ | |
| - name: Extract database files | |
| run: | | |
| # Extract iOS cache | |
| unzip -o ./apps/website/public/ios-cache.zip -d ./apps/tool/assets/ios/ | |
| # Extract Android cache | |
| unzip -o ./apps/website/public/android-cache.zip -d ./apps/tool/assets/android/ | |
| - name: Export database data | |
| run: pnpm nx run tool:export-dbs | |
| - name: Build Next.js site | |
| run: pnpm nx run website:build | |
| env: | |
| NEXT_PUBLIC_BUILD_DATE: ${{ github.event.head_commit.timestamp || github.event.repository.pushed_at }} | |
| NEXT_PUBLIC_BUILD_NUMBER: ${{ github.run_number }} | |
| NEXT_PUBLIC_COMMIT_SHA: ${{ github.sha }} | |
| GITHUB_ACTIONS: true | |
| deploy-pages: | |
| needs: [build-ios, build-android] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| name: Setup pnpm | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: ".nvmrc" | |
| cache: "pnpm" | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Download iOS artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ios-cache | |
| path: ./apps/website/public/ | |
| - name: Download Android artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: android-cache | |
| path: ./apps/website/public/ | |
| - name: Extract database files | |
| run: | | |
| # Extract iOS cache | |
| unzip -o ./apps/website/public/ios-cache.zip -d ./apps/tool/assets/ios/ | |
| # Extract Android cache | |
| unzip -o ./apps/website/public/android-cache.zip -d ./apps/tool/assets/android/ | |
| - name: Export database data | |
| run: pnpm nx run tool:export-dbs | |
| - name: Build Next.js site | |
| run: pnpm nx run website:build | |
| env: | |
| NEXT_PUBLIC_BUILD_DATE: ${{ github.event.head_commit.timestamp || github.event.repository.pushed_at }} | |
| NEXT_PUBLIC_BUILD_NUMBER: ${{ github.run_number }} | |
| NEXT_PUBLIC_COMMIT_SHA: ${{ github.sha }} | |
| GITHUB_ACTIONS: true | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload to GitHub Pages | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./dist/apps/website/.next | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |