---
kind: pipeline
type: docker
name: Android

steps:
- name: prepare signing
  image: busybox
  environment:
    STOREPASSWORD:
      from_secret: StorePassword
    KEYPASSWORD:
      from_secret: KeyPassword
  commands:
  - touch keystore.properties
  - echo "storePassword=$STOREPASSWORD" >> keystore.properties
  - echo "keyPassword=$KEYPASSWORD" >> keystore.properties
  - echo "keyAlias=key0" >> keystore.properties
  - echo "storeFile=../AndroidKey" >> keystore.properties

- name: build
  image: mingc/android-build-box
  commands:
  - ./gradlew test
  - ./gradlew assembleDebug
  - ./gradlew bundleRelease

- name: deploy laatest buuild
  image: busybox
  volumes:
  - name: deploy
    path: /tmp/deploy
  commands:
  - mkdir -p /tmp/deploy/lastBuild
  - cp ./app/build/outputs/apk/debug/app-debug.apk /tmp/deploy/lastBuild/app-debug.apk
  - cp ./app/build/outputs/bundle/release/app-release.aab /tmp/deploy/lastBuild/app-release.aab

- name: slack notification
  image: plugins/slack
  settings:
    webhook:
      from_secret: SlackWebhook

volumes:
  - name: deploy
    host:
      path: /mnt/seafile-sync-cli/TichuCounter