1
1
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-license.md
2
2
name : Check License
3
3
4
- env :
5
- EXPECTED_LICENSE_FILENAME : LICENSE.txt
6
- # SPDX identifier: https://spdx.org/licenses/
7
- EXPECTED_LICENSE_TYPE : GPL-3.0
8
-
9
4
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
10
5
on :
11
6
create :
35
30
jobs :
36
31
run-determination :
37
32
runs-on : ubuntu-latest
33
+ permissions : {}
38
34
outputs :
39
35
result : ${{ steps.determination.outputs.result }}
40
36
steps :
57
53
echo "result=$RESULT" >> $GITHUB_OUTPUT
58
54
59
55
check-license :
56
+ name : ${{ matrix.check-license.path }}
60
57
needs : run-determination
61
58
if : needs.run-determination.outputs.result == 'true'
62
59
runs-on : ubuntu-latest
60
+ permissions :
61
+ contents : read
62
+
63
+ strategy :
64
+ fail-fast : false
65
+
66
+ matrix :
67
+ check-license :
68
+ - path : ./
69
+ expected-filename : LICENSE.txt
70
+ # SPDX identifier: https://spdx.org/licenses/
71
+ expected-type : GPL-3.0
63
72
64
73
steps :
65
74
- name : Checkout repository
@@ -73,23 +82,27 @@ jobs:
73
82
- name : Install licensee
74
83
run : gem install licensee
75
84
76
- - name : Check license file
85
+ - name : Check license file for ${{ matrix.check-license.path }}
77
86
run : |
78
87
EXIT_STATUS=0
88
+
89
+ # Go into folder path
90
+ cd ./${{ matrix.check-license.path }}
91
+
79
92
# See: https://github.com/licensee/licensee
80
93
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
81
94
82
95
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
83
96
echo "Detected license file: $DETECTED_LICENSE_FILE"
84
- if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME }\"" ]; then
85
- echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: $EXPECTED_LICENSE_FILENAME "
97
+ if [ "$DETECTED_LICENSE_FILE" != "\"${{ matrix.check-license.expected-filename } }\"" ]; then
98
+ echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: ${{ matrix.check-license.expected-filename }} "
86
99
EXIT_STATUS=1
87
100
fi
88
101
89
102
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
90
103
echo "Detected license type: $DETECTED_LICENSE_TYPE"
91
- if [ "$DETECTED_LICENSE_TYPE" != "\"${EXPECTED_LICENSE_TYPE }\"" ]; then
92
- echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${EXPECTED_LICENSE_TYPE }\""
104
+ if [ "$DETECTED_LICENSE_TYPE" != "\"${{ matrix.check-license.expected-type } }\"" ]; then
105
+ echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${{ matrix.check-license.expected-type } }\""
93
106
EXIT_STATUS=1
94
107
fi
95
108
0 commit comments