name: Release

on:
  push:
    branches:
      - main

jobs:
  build:
    if: "contains(github.event.head_commit.message, vars.SKIP_CI_PREFIX) != true"

    runs-on: runner
    steps:
      - name: Checkout repository
        uses: https://antoine-roux.tk/projects/actions/checkout@v4.1.8
        with:
          fetch-depth: 0
          fetch-tags: false

      - name: Setup java
        uses: https://antoine-roux.tk/projects/actions/setup-java@v1.1.0

      - name: Deploy container artifact
        run: ./mvnw compile jib:build

      - name: Deploy maven jar artifact
        run: ./mvnw deploy
        env:
          MAVEN_ARGS: "-s ${{ gitea.workspace }}/settings.xml"
          TOKEN_REGISTRY: ${{ secrets.TOKEN_REGISTRY }}

      - name: Auto generate changelog
        uses: https://antoine-roux.tk/projects/actions/auto-changie@v1.0.2

      - name: Push changelog
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "${{ vars.SKIP_CI_PREFIX }} Push updated changelog"
          file_pattern: "\\.changes/* CHANGELOG.md .changie.yaml"