on:
  workflow_dispatch:
  push:
    tags:
      - 'jre-alpine*.**.*/v**'
  schedule:
    - cron: '0 0 1-31 1-12 1'

jobs:
  build_push:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout Repository
        #uses: actions/checkout@v5
        #uses: https://github.com/yangskyboxlabs/action-checkout@sha256
        uses: https://git.nanody.de/anonoe/action-checkout@sha256
        with:
          object-format: 'sha256'
      -
        name: Login to Container Registry
        uses: docker/login-action@v3
        with:
          registry: git.nanody.de
          username: ${{ github.actor }}
          password: ${{ secrets.PACKAGES_RW }}
      -
        name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: |
            git.nanody.de/anonoe/jre-alpine
          tags: |
            type=schedule,pattern=nightly,suffix={{tag}}-{{commit_date 'YYYYMMDD-HHmmss' tz='Europe/Berlin'}}
            type=semver,pattern={{version}},match=v(\d.\d.\d)$
            type=semver,pattern={{major}}.{{minor}},match=v(\d.\d.\d)$
            type=semver,pattern={{major}},match=v(\d.\d.\d)$
          #  type=raw,suffix={{tag}}-{{commit_date 'YYYYMMDD-HHmmss' tz='Europe/Berlin'}},value=
      -
        name: Build and push jre-alpine
        uses: docker/build-push-action@v6
        with:
          context: ./server/buildenv-jre-alpine/
          file: ./server/buildenv-jre-alpine/Containerfile
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          #labels: ${{ steps.meta.outputs.labels }}
