Skip to content

Commit 4991b2e

Browse files
authored
Merge pull request #11 from per1234/sync-check-license
Sync "Check License" CI workflow with template
2 parents 1f66931 + f1181ed commit 4991b2e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

.github/workflows/check-license.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-license.md
12
name: Check License
23

34
env:
45
EXPECTED_LICENSE_FILENAME: LICENSE.txt
56
# SPDX identifier: https://spdx.org/licenses/
67
EXPECTED_LICENSE_TYPE: CC0-1.0
78

8-
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
9+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
910
on:
1011
push:
1112
paths:
12-
- ".github/workflows/check-license.yml"
13+
- ".github/workflows/check-license.ya?ml"
1314
# See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file
1415
- "[cC][oO][pP][yY][iI][nN][gG]*"
1516
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
@@ -18,7 +19,7 @@ on:
1819
- "[pP][aA][tT][eE][nN][tT][sS]*"
1920
pull_request:
2021
paths:
21-
- ".github/workflows/check-license.yml"
22+
- ".github/workflows/check-license.ya?ml"
2223
- "[cC][oO][pP][yY][iI][nN][gG]*"
2324
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
2425
- "[lL][iI][cC][eE][nN][cCsS][eE]*"
@@ -45,19 +46,22 @@ jobs:
4546

4647
- name: Check license file
4748
run: |
49+
EXIT_STATUS=0
4850
# See: https://github.com/licensee/licensee
4951
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
5052
5153
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
5254
echo "Detected license file: $DETECTED_LICENSE_FILE"
53-
if [ "$DETECTED_LICENSE_FILE" != "\"$EXPECTED_LICENSE_FILENAME\"" ]; then
54-
echo "ERROR: detected license file doesn't match expected: $EXPECTED_LICENSE_FILENAME"
55-
exit 1
55+
if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME}\"" ]; then
56+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: $EXPECTED_LICENSE_FILENAME"
57+
EXIT_STATUS=1
5658
fi
5759
5860
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
5961
echo "Detected license type: $DETECTED_LICENSE_TYPE"
60-
if [ "$DETECTED_LICENSE_TYPE" != "\"$EXPECTED_LICENSE_TYPE\"" ]; then
61-
echo "ERROR: detected license type doesn't match expected $EXPECTED_LICENSE_TYPE"
62-
exit 1
62+
if [ "$DETECTED_LICENSE_TYPE" != "\"${EXPECTED_LICENSE_TYPE}\"" ]; then
63+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${EXPECTED_LICENSE_TYPE}\""
64+
EXIT_STATUS=1
6365
fi
66+
67+
exit $EXIT_STATUS

0 commit comments

Comments
 (0)