name: Check which packages changed

permissions: read-all

on:
  workflow_call:
    inputs:
      check-mergeable-state:
        default: false
        type: boolean
    outputs:
      changes:
        description: 'The packages that were changed for this PR'
        value: ${{ jobs.check-changes.outputs.changes }}
jobs:
  check-changes:
    name: Check which packages changed
    runs-on: ubuntu-latest
    outputs:
      changes: ${{ steps.changes.outputs.changes }}
    steps:
      - name: Check out repository
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          fetch-depth: 2
      - name: Set up Node.js
        uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
        with:
          cache: npm
          node-version-file: '.nvmrc'
      - name: Install dependencies
        run: npm ci
        env:
          PUPPETEER_SKIP_DOWNLOAD: true
      # Set up GitHub Actions caching for Wireit.
      - uses: google/wireit@9d7c2e5346f8ef1b1ab6014c4e96c74e234f7ed5 # setup-github-actions-caching/v2.0.4
      - name: Build packages
        run: npm run build
      - name: Detect changed packages
        uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
        id: changes
        with:
          filters: |
            puppeteer:
              - '.nvmrc'
              - '.github/workflows/ci.yml'
              - 'packages/browsers/src/install.ts'
              - 'packages/browsers/src/browser-data/firefox.ts'
              - 'packages/browsers/src/fileUtil.ts'
              - 'packages/puppeteer/**'
              - 'packages/puppeteer-core/**'
              - 'packages/testserver/**'
              - 'examples/puppeteer-in-extension/**'
              - 'examples/puppeteer-in-browser/**'
              - 'docker/**'
              - 'test/**'
              - 'test-d/**'
              - 'tools/mocha-runner/**'
              - '.mocharc.cjs'
              - 'tools/doctest/**'
              - 'tsconfig.base.json'
            website:
              - '.nvmrc'
              - '.github/workflows/ci.yml'
              - 'docs/**'
              - 'website/**'
              - 'README.md'
              - 'tsconfig.base.json'
            ng-schematics:
              - '.nvmrc'
              - '.github/workflows/ci.yml'
              - 'packages/ng-schematics/**'
              - 'tsconfig.base.json'
            browsers:
              - '.nvmrc'
              - '.github/workflows/ci.yml'
              - 'packages/browsers/**'
              - 'tsconfig.base.json'
