name: Merge
on:
  pull_request:
    types:
      - closed
    branches:
      - main
concurrency:
  group: merge-${{ github.event.pull_request.base.ref }}
  cancel-in-progress: false
jobs:
  build-library:
    name: Library ${{ matrix.architecture }}
    if: github.event.pull_request.merged == true
    strategy:
      fail-fast: false
      matrix:
        include:
          - architecture: x86_64-linux
            runner: depot-ubuntu-24.04-4
          - architecture: aarch64-linux
            runner: depot-ubuntu-24.04-arm-4
          - architecture: aarch64-darwin
            runner: depot-macos-15
    uses: hoprnet/hopr-workflows/.github/workflows/build-library.yaml@build-library-v2
    permissions:
      contents: read
    with:
      source_branch: ${{ github.event.pull_request.base.ref }}
      version_type: pr
      architecture: ${{ matrix.architecture }}
      timeout_minutes: 120
      package_name: hopr-api
      runner: ${{ matrix.runner }}
    secrets:
      cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }}
  notify:
    name: Notify failure
    needs: [build-library]
    if: ${{ always() && github.event.pull_request.merged == true && !success() }}
    runs-on: depot-ubuntu-24.04
    permissions: {}
    steps:
      - name: Notify failed merge pipeline
        uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2
        with:
          api-key: ${{ secrets.ZULIP_API_KEY }}
          email: ${{ secrets.ZULIP_EMAIL }}
          organization-url: "https://hopr.zulipchat.com"
          type: stream
          to: HOPRd
          topic: main
          content: |
            The merge pipeline has failed for pull request [#${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
