name: CI
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup Java JDK
        uses: actions/setup-java@v1.3.0
        with:
          java-version: "12.x"
      
      - name: Flutter action
        uses: subosito/flutter-action@v1.1.1
        with:
          channel: "stable"
          flutter-version: "1.12.x"
      
      - name: Cache Dependencies
        id: cache
        uses: actions/cache@v1
        with:
          path: node_modules
          key: ${{runner.OS}}-npm-caches-${{ hashFiles('pubspec.lock') }}

      - name: Install Dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: flutter pub get

      - run: flutter build apk --release

      # output some file:
      - name: artifact
        uses: actions/upload-artifact@v1
        with:
          name: chat-app-ui
          path: build/app/outputs
      
      # #  Release
      # - name: Release apk
      #   uses: ncipollo/release-action@v1.5.0
      #   with:
      #     artifacts: "build/app/outputs/apk/release/*.apk"
      #     token: ${{ secrets.GITHUB_RElEASE_TOKEN }}