name: Build App
on:
  push:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: 🏗 Setup repo
      uses: actions/checkout@v2

    - name: 🏗 Setup Node
      uses: actions/setup-node@v2
      with:
        node-version: 22

    - name: 🏗 Setup pnpm
      uses: pnpm/action-setup@v4
      with:
        version: latest

    - name: 🏗 Setup Expo and EAS
      uses: expo/expo-github-action@v8
      with:
        token: ${{ secrets.EXPO_TOKEN }}
        eas-version: latest
        packager: pnpm

    - name: 📦 Install dependencies
      run: pnpm install
      working-directory: mobile

    - name: 👷 Build app
      run: |
        eas build --local \
          --non-interactive \
          --output=./app-build \
          --platform=android \
          --profile=preview
      working-directory: mobile

    - name: 📤 Upload build artifact
      uses: actions/upload-artifact@v4
      with:
        name: android-preview-build.zip
        path: mobile/app-build/*
        if-no-files-found: error
