name: 3PP License Check

on:
  push:
    branches:
      - master
    paths:
      - 'package-lock.json'
  workflow_dispatch:
  pull_request:
    branches:
      - master
    paths:
      - 'package-lock.json'
  schedule:
    - cron: '0 4 * * *' # Runs every day at 4am: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule

jobs:
  License-check:
    name: 3PP License Check

    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-22.04]
        node: ['24.x']
        java: ['11']

    runs-on: ${{ matrix.os }}
    timeout-minutes: 60

    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          fetch-depth: 2

      - name: Use Node.js ${{ matrix.node }}
        uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
        with:
          node-version: ${{ matrix.node }}
          registry-url: 'https://registry.npmjs.org'

      - name: Use Java ${{ matrix.java }}
        uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
        with:
          distribution: 'adopt'
          java-version: ${{ matrix.java }}

      - name: Run dash-licenses check
        shell: bash
        run: |
          npm ci
          npm run license:check
