Skip to content

Commit fc03b9f

Browse files
committed
feat(workflows): Add license check workflow
This commit introduces a new GitHub Actions workflow to automatically check the license of the repository. The workflow consists of three jobs: 1. `find_license_file`: Locates the license file in the repository. 2. `classify_license`: Uses the `billnapier/licenseclassifier` reusable workflow to classify the license. 3. `verify_license`: Checks if the classified license is one of the allowed licenses (Apache-2.0, BSD-3-Clause, MIT).
1 parent 6445b8d commit fc03b9f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Check License
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
find_license_file:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
filename: ${{ steps.find_license.outputs.filename }}
17+
steps:
18+
- name: Check out code
19+
uses: actions/checkout@v3
20+
21+
- name: Find license file
22+
id: find_license
23+
run: |
24+
if [[ -f "LICENSE" ]]; then
25+
echo "filename=LICENSE" >> $GITHUB_OUTPUT
26+
elif [[ -f "LICENSE.md" ]]; then
27+
echo "filename=LICENSE.md" >> $GITHUB_OUTPUT
28+
elif [[ -f "LICENSE.txt" ]]; then
29+
echo "filename=LICENSE.txt" >> $GITHUB_OUTPUT
30+
elif [[ -f "COPYING" ]]; then
31+
echo "filename=COPYING" >> $GITHUB_OUTPUT
32+
else
33+
echo "::error::No license file found. Checked for LICENSE, LICENSE.md, LICENSE.txt, COPYING."
34+
exit 1
35+
fi
36+
37+
classify_license:
38+
needs: find_license_file
39+
uses: billnapier/licenseclassifier/.github/workflows/classify.yml@93323eec88c7e44543bab2583c8347df9cb7314e
40+
with:
41+
file_to_classify: ${{ needs.find_license_file.outputs.filename }}
42+
43+
verify_license:
44+
runs-on: ubuntu-latest
45+
needs: classify_license
46+
steps:
47+
- name: Verify license
48+
run: |
49+
license_name="${{ needs.classify_license.outputs.license_name }}"
50+
echo "Detected license: $license_name"
51+
if [[ "$license_name" == "Apache-2.0" || "$license_name" == "BSD-3-Clause" || "$license_name" == "MIT" ]]; then
52+
echo "License is compliant."
53+
else
54+
echo "::error::License '$license_name' is not one of the allowed licenses (Apache-2.0, BSD-3-Clause, MIT)."
55+
exit 1
56+
fi

0 commit comments

Comments
 (0)