on:
  #release:
    #types: [published]
  push:
    branches:
       - "master"
   
jobs:
  build-image:
    runs-on: ubuntu-act-latest
    steps:
      - 
        name: Check Out Repo
        uses: https://github.com/actions/checkout@v4
        #with:
            #repository: jj/paolu-mybatis
            #path: master
            #token: ''
      - name: Set Java Action
        id: steps1
        uses: https://github.com/actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 21
          #cache: maven
          #cache-dependency-path: .pom.xml
      - 
        name: Set Maven Action
        uses: https://github.com/stCarolas/setup-maven@v5
        with:
          maven-version: 3.9.6
      - 
        name: Cache
        uses: actions/cache@v4
        id: cache1
        with:
          path: ~/.m2/repository
          key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
          restore-keys: |
            ${{ runner.os }}-maven-
      #- name: Set repo-java-maven Env
        #uses: https://github.com/s4u/setup-maven-action@v1.11.0
        #with:
          #java-distribution: temurin
          #java-version: 20
          #maven-version: 3.9.5
      - if: ${{ steps.cache1.outputs.cache-hit == 'true' }}
        name:  is hit cache
        continue-on-error: true
        run: echo " hit cache ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}"
      - 
        name: Build With Maven
        run: mvn -B package -Dmaven.test.skip
      - name: Uzip
        run: mkdir -p target/dependency && (cd target/dependency; jar -xf ../*.jar)
      #- 
        #name: set up qemu
        #uses: https://github.com/docker/setup-qemu-action@v3
      -
        name: Set Docker Buildx
        uses: https://github.com/docker/setup-buildx-action@v3
      -
        name: Login To Zot
        uses: https://github.com/docker/login-action@v3
        with:
          registry: zot.164500.xyz
          username: test
          password: test
      -
        name: Build And Push Image To Zot
        uses: https://github.com/docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: zot.164500.xyz/jj/yx:latest