From 37168fa316d0e892139d6f93e0aba494aa9f976a Mon Sep 17 00:00:00 2001
From: Sebastian Schildt <sebastian.schildt@de.bosch.com>
Date: Sun, 26 Jan 2025 17:09:22 +0100
Subject: [PATCH] Add SPDX identifier check to GHA

Signed-off-by: Sebastian Schildt <sebastian.schildt@de.bosch.com>
---
 .github/workflows/spdxcheck.yml | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 .github/workflows/spdxcheck.yml

diff --git a/.github/workflows/spdxcheck.yml b/.github/workflows/spdxcheck.yml
new file mode 100644
index 0000000..0690d7d
--- /dev/null
+++ b/.github/workflows/spdxcheck.yml
@@ -0,0 +1,30 @@
+name: Check SPDX identifiers
+
+on:
+  pull_request:
+    branches: [main]
+
+jobs:
+  check-spdx-headers:
+    name: Check SPDX headers
+
+    runs-on: ubuntu-latest
+    env:
+      licenses: "BSD-3-Clause"
+
+    steps:
+    - name: Checkout code
+      uses: actions/checkout@v4
+      with:
+        # required to grab the history of the PR
+        fetch-depth: 0
+
+    - name: Get files changed in PR
+      run: |
+        echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | tr '\n' ',')" >> $GITHUB_ENV
+
+    - name: Check added or modified files for correct SPDX identifiers
+      uses: eclipse-kuksa/kuksa-actions/spdx@4
+      with:
+        files: "${{ env.files }}"
+        licenses: "${{ env.licenses }}"