name: License Header Check on: pull_request: types: [opened, synchronize, reopened] branches: [master] env: HEADER_CHECK_LINES: 10 LICENSE: "LicenseRef-ScyllaDB-Source-Available-1.1" CHECKED_EXTENSIONS: ".cc .hh .py" FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true jobs: check-license-headers: name: Check License Headers runs-on: ubuntu-latest permissions: pull-requests: write steps: - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 - name: Get changed files id: changed-files run: | # Get list of added files comparing with base branch echo "files=$(git diff --name-only --diff-filter=A ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr '\n' ' ')" >> $GITHUB_OUTPUT - name: Check license headers if: steps.changed-files.outputs.files != '' run: | .github/scripts/check-license.py \ --files ${{ steps.changed-files.outputs.files }} \ --license "${{ env.LICENSE }}" \ --check-lines "${{ env.HEADER_CHECK_LINES }}" \ --extensions ${{ env.CHECKED_EXTENSIONS }} - name: Comment on PR if check fails if: failure() uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 with: script: | const license = '${{ env.LICENSE }}'; await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `❌ License header check failed. Please ensure all new files include the header within the first ${{ env.HEADER_CHECK_LINES }} lines:\n\`\`\`\n${license}\n\`\`\`\nSee action logs for details.` });