name: docker-gorgone-testing

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

on:
  workflow_dispatch:
  push:
    branches:
      - develop
      - dev-[2-9][0-9].[0-9][0-9].x
    paths:
      - ".github/docker/Dockerfile.gorgone-testing-*"
      - ".github/workflows/docker-gorgone-testing.yml"
  pull_request:
    paths:
      - ".github/docker/Dockerfile.gorgone-testing-*"
      - ".github/workflows/docker-gorgone-testing.yml"

jobs:
  get-environment:
    uses: ./.github/workflows/get-environment.yml

  dockerize:
    needs: [get-environment]
    runs-on: ubuntu-24.04

    strategy:
      matrix:
        distrib: [alma8, alma9, bookworm, jammy]
    steps:
      - name: Checkout sources
        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

      - name: Login to registry
        uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
        with:
          registry: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}
          username: ${{ secrets.HARBOR_CENTREON_PUSH_USERNAME }}
          password: ${{ secrets.HARBOR_CENTREON_PUSH_TOKEN }}

      - uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

      - uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 # v6.5.0
        with:
          file: .github/docker/Dockerfile.gorgone-testing-${{ matrix.distrib }}
          context: .
          build-args: |
            "VERSION=${{ needs.get-environment.outputs.major_version }}"
          pull: true
          push: true
          tags: ${{ vars.DOCKER_INTERNAL_REGISTRY_URL }}/gorgone-testing-${{ matrix.distrib }}:${{ needs.get-environment.outputs.gorgone_docker_version }}
