.github: skip license check when no relevant files changed

Skip the license header check step in `check-license-header.yaml` workflow
when no files with configured extensions were changed in the pull request.
Previously, the workflow would fail in this case since the --files
argument requires at least one file path:

```
  check-license.py: error: argument --files: expected at least one argument
```

Add `if` condition to only run the check when steps.changed-files.outputs.files
is not empty.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2025-02-07 09:59:04 +08:00
parent c33bbc884b
commit 342b640b4b

View File

@@ -28,6 +28,7 @@ jobs:
echo "files=$(git diff --name-only --diff-filter=A ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr '\n' ' ')" >> $GITHUB_OUTPUT 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 - name: Check license headers
if: steps.changed-files.outputs.files != ''
run: | run: |
.github/scripts/check-license.py \ .github/scripts/check-license.py \
--files ${{ steps.changed-files.outputs.files }} \ --files ${{ steps.changed-files.outputs.files }} \