name: Browser Extension Build

on:
  push:
    branches: [ "main" ]
    paths:
      - 'apps/browser-extension/**'
      - 'core/**'
      - '.github/workflows/browser-extension-build.yml'
      - '.github/actions/build-browser-extension/**'
      - '.github/actions/build-core-libraries/**'
  pull_request:
    branches: [ "main" ]
    paths:
      - 'apps/browser-extension/**'
      - 'core/**'
      - '.github/workflows/browser-extension-build.yml'
      - '.github/actions/build-browser-extension/**'
      - '.github/actions/build-core-libraries/**'
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build-core-libraries:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build Core Libraries
        uses: ./.github/actions/build-core-libraries

  build-chrome-extension:
    needs: build-core-libraries
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build Chrome Extension
        uses: ./.github/actions/build-browser-extension
        with:
          browser: chrome

  build-firefox-extension:
    needs: build-core-libraries
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build Firefox Extension
        uses: ./.github/actions/build-browser-extension
        with:
          browser: firefox

  build-edge-extension:
    needs: build-core-libraries
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build Edge Extension
        uses: ./.github/actions/build-browser-extension
        with:
          browser: edge
