## %CopyrightBegin%
##
## SPDX-License-Identifier: Apache-2.0
##
## Copyright Ericsson AB 2024-2026. All Rights Reserved.
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
##     http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## %CopyrightEnd%

## This workflow will scan pull requests and pushed for files that do not
## have the proper license.

name: Check license header

on:
  pull_request:
  push:

permissions:
  contents: read
  pull-requests: read

jobs:
  run-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # ratchet:actions/checkout@v6.0.2
        with:
            fetch-depth: '0'
            persist-credentials: false
      - uses: erlef/setup-beam@e6d7c94229049569db56a7ad5a540c051a010af9 # ratchet:erlef/setup-beam@v1.20.4
        with:
            otp-version: '27'

      - name: License Compliance Check all files
        run: ./scripts/license-header.es ci

      - name: Check that copyright update works as it should
        run: |
          ./scripts/license-header.es update
          ./scripts/license-header.es ci
