name: _TAG

on:
  workflow_dispatch:
  push:
    tags:
      - '*'

jobs:
  build-bundle:
    uses: ./.github/workflows/build-bundle.yml
    secrets: inherit
    with:
      gh_ref: ${{ github.ref_name }}

  build-docker:
    needs: build-bundle
    uses: ./.github/workflows/build-docker.yml
    secrets: inherit
    with:
      gh_ref: ${{ github.ref_name }}

  build-docker-admin-console:
    uses: ./.github/workflows/build-docker-admin-console.yml
    secrets: inherit
    with:
      gh_ref: ${{ github.ref_name }}

  notify:
    name: Notifications
    runs-on: ubuntu-24.04
    needs:
      - build-docker
      - build-docker-admin-console
    steps:
      - name: Notify Mattermost
        uses: mattermost/action-mattermost-notify@ae31bb6f9e26a54336e79696f108a2c91cf55b4e # v2.1.0
        with:
          MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK }}
          MATTERMOST_CHANNEL: bot-alerts-cicd
          TEXT: |
            🐳 *[PENPOT] Docker image available: ${{ github.ref_name }}*
            🔗 Run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
            @infra

  publish-final-tag:
    if: ${{ !contains(github.ref_name, '-RC') && !contains(github.ref_name, '-alpha') && !contains(github.ref_name, '-beta')  && contains(github.ref_name, '.') }}
    needs:
      - build-docker
      - build-docker-admin-console
    uses: ./.github/workflows/release.yml
    secrets: inherit
    with:
      gh_ref: ${{ github.ref_name }}
