From 84737a4750eeae5f9237bd7d5727466fa94f892a Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Tue, 21 Nov 2023 19:56:28 +0100 Subject: [PATCH] feat: Add path options for `check-license.yml` --- workflow-templates/check-license.md | 1 + workflow-templates/check-license.yml | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/workflow-templates/check-license.md b/workflow-templates/check-license.md index cc0eb8d6..e0c391ea 100644 --- a/workflow-templates/check-license.md +++ b/workflow-templates/check-license.md @@ -14,6 +14,7 @@ Install the [`check-license.yml`](check-license.yml) GitHub Actions workflow to - Configure the license filename in the `env.EXPECTED_LICENSE_FILENAME` field of `check-license.yml`. - Configure the license type in the `env.EXPECTED_LICENSE_TYPE` field of `check-license.yml`. +- (Optional) If license files should be present outisde the root directory, configure additional `path:` locations. ### Readme badge diff --git a/workflow-templates/check-license.yml b/workflow-templates/check-license.yml index e5a825c6..63c556e2 100644 --- a/workflow-templates/check-license.yml +++ b/workflow-templates/check-license.yml @@ -66,6 +66,14 @@ jobs: permissions: contents: read + strategy: + fail-fast: false + + matrix: + module: + #TODO Add additional paths where license files should be + - path: + steps: - name: Checkout repository uses: actions/checkout@v4 @@ -78,12 +86,18 @@ jobs: - name: Install licensee run: gem install licensee - - name: Check license file + - name: Check license file for ${{ matrix.module.path }} run: | EXIT_STATUS=0 + + # Go into folder path + cd ./${{ matrix.module.path }} + + # See: https://github.com/licensee/licensee LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)" + DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')" echo "Detected license file: $DETECTED_LICENSE_FILE" if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME}\"" ]; then