name: Check Android

on:
  pull_request:
    branches: ["main"]

permissions:
  contents: write

jobs:
  android-check:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./materialious/android

    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: latest

      - name: Install modules
        run: cd ../ && npm install

      - name: Build android nodejs packages
        run: cd ../static/nodejs-android && npm install

      - name: Build package
        run: cd ../ && npm run build

      - name: Sync package
        run: cd ../ && npx cap sync

      - name: Setup JDK
        uses: actions/setup-java@v3
        with:
          distribution: "zulu"
          java-version: "21"
          cache: "gradle"

      - name: Build App
        run: |
          bash gradlew assembleRelease
          bash gradlew bundleRelease
