name: Build Debug App

on:
  push:
  pull_request:
  workflow_dispatch:

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup JDK 21
        uses: actions/setup-java@v4
        with:
          java-version: 21
          distribution: zulu

      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@v4
        with:
          cache-read-only: ${{ github.event_name == 'pull_request' }}

      - name: Build with Gradle
        run: ./gradlew :app:assembleDebug :app:assembleStaging --stacktrace

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: app
          if-no-files-found: error
          path: |
            app/build/outputs/apk/debug/app-debug.apk
            app/build/outputs/apk/staging/app-staging.apk
