11# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-license.md
22name : Check License
33
4- env :
5- EXPECTED_LICENSE_FILENAME : LICENSE.txt
6- # SPDX identifier: https://spdx.org/licenses/
7- EXPECTED_LICENSE_TYPE : GPL-3.0
8-
94# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
105on :
116 create :
3530jobs :
3631 run-determination :
3732 runs-on : ubuntu-latest
33+ permissions : {}
3834 outputs :
3935 result : ${{ steps.determination.outputs.result }}
4036 steps :
5753 echo "result=$RESULT" >> $GITHUB_OUTPUT
5854
5955 check-license :
56+ name : ${{ matrix.check-license.path }}
6057 needs : run-determination
6158 if : needs.run-determination.outputs.result == 'true'
6259 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
6372
6473 steps :
6574 - name : Checkout repository
@@ -73,23 +82,27 @@ jobs:
7382 - name : Install licensee
7483 run : gem install licensee
7584
76- - name : Check license file
85+ - name : Check license file for ${{ matrix.check-license.path }}
7786 run : |
7887 EXIT_STATUS=0
88+
89+ # Go into folder path
90+ cd ./${{ matrix.check-license.path }}
91+
7992 # See: https://github.com/licensee/licensee
8093 LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
8194
8295 DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
8396 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 }} "
8699 EXIT_STATUS=1
87100 fi
88101
89102 DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
90103 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 } }\""
93106 EXIT_STATUS=1
94107 fi
95108
0 commit comments