name: Auto Deploy Docker

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Cache Maven Repository
      uses: actions/cache@v1
      with:
        path: ~/.m2
        key: jetlinks-community-maven-repository
    - name: Build with Maven
      run: mvn -B package && cd jetlinks-standalone && mvn docker:build
    - name: Login Docker Repo
      run: echo "${{ secrets.ALIYUN_DOCKER_REPO_PWD }}" | docker login registry.cn-shenzhen.aliyuncs.com -u ${{ secrets.ALIYUN_DOCKER_REPO_USERNAME }} --password-stdin
    - name: Push Docker
      run: docker push registry.cn-shenzhen.aliyuncs.com/jetlinks/jetlinks-standalone:$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
