---
name: Publish
on:  # yamllint disable-line rule:truthy
  push:
    branches:
      - main
jobs:
  ci:
    name: Run ci
    uses: ./.github/workflows/ci.yml

  build:
    name: Build Alertmanager for all architectures
    runs-on: ubuntu-latest
    strategy:
      matrix:
        thread: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
    needs: ci
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4
      - uses: ./.github/promci/actions/build
        with:
          parallelism: 12
          thread: ${{ matrix.thread }}
  publish_main:
    name: Publish main branch artefacts
    runs-on: ubuntu-latest
    needs: build
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - uses: prometheus/promci@fc721ff8497a70a93a881cd552b71af7fb3a9d53 # v0.5.4
      - uses: ./.github/promci/actions/publish_main
        with:
          docker_hub_login: ${{ secrets.docker_hub_login }}
          docker_hub_password: ${{ secrets.docker_hub_password }}
          quay_io_login: ${{ secrets.quay_io_login }}
          quay_io_password: ${{ secrets.quay_io_password }}
