name: Push Container Image with Gradle

on:
  release:
    types: [published]

permissions:
  contents: read
  packages: write

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 0
    - name: Install graphviz
      run: sudo apt-get install graphviz
    - name: Install podman
      run: sudo apt-get install podman
    - name: Log in to the Container registry
      uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
      with:
        registry: ghcr.io
        username: ${{ github.actor }}
        password: ${{ secrets.GITHUB_TOKEN }}
    - name: Set up JDK 17
      uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'temurin'
    - name: Push with Gradle
      run: ./gradlew -Pdocker.registry=ghcr.io/${{ github.actor }} pushImages
