|
@@ -0,0 +1,61 @@
|
|
|
+name: Reusable - License check
|
|
|
+
|
|
|
+on:
|
|
|
+ workflow_call:
|
|
|
+ inputs:
|
|
|
+ cache-read-only:
|
|
|
+ type: boolean
|
|
|
+ required: false
|
|
|
+ no-build-cache:
|
|
|
+ type: boolean
|
|
|
+ required: false
|
|
|
+ secrets:
|
|
|
+ GRADLE_ENTERPRISE_ACCESS_KEY:
|
|
|
+ required: false
|
|
|
+ GE_CACHE_USERNAME:
|
|
|
+ required: false
|
|
|
+ GE_CACHE_PASSWORD:
|
|
|
+ required: false
|
|
|
+
|
|
|
+jobs:
|
|
|
+ license-check:
|
|
|
+ runs-on: ubuntu-latest
|
|
|
+ steps:
|
|
|
+ - uses: actions/checkout@v3
|
|
|
+
|
|
|
+ - name: Set up JDK for running Gradle
|
|
|
+ uses: actions/setup-java@v3
|
|
|
+ with:
|
|
|
+ distribution: temurin
|
|
|
+ java-version: 17
|
|
|
+
|
|
|
+ - name: Generate license report
|
|
|
+ uses: gradle/gradle-build-action@v2
|
|
|
+ env:
|
|
|
+ GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
|
|
|
+ GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
|
|
|
+ GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
|
|
|
+ with:
|
|
|
+ # currently ignoring inputs.no-build-cache and always running with --no-build-cache
|
|
|
+ # see https://github.com/jk1/Gradle-License-Report/issues/231
|
|
|
+ arguments: generateLicenseReport --no-build-cache
|
|
|
+ cache-read-only: ${{ inputs.cache-read-only }}
|
|
|
+ # gradle enterprise is used for the build cache
|
|
|
+ gradle-home-cache-excludes: caches/build-cache-1
|
|
|
+
|
|
|
+ - name: Check licenses
|
|
|
+ run: |
|
|
|
+ # add any untracked folders that may have been added by generateLicenseReport
|
|
|
+ git add licenses
|
|
|
+ # there's always going to one line difference due to the timestamp included in the report
|
|
|
+ if [[ $(git diff --cached --shortstat licenses) == " 1 file changed, 1 insertion(+), 1 deletion(-)" ]]
|
|
|
+ then
|
|
|
+ echo "Licenses are up-to-date."
|
|
|
+ else
|
|
|
+ echo "Licenses are not up-to-date, please run './gradlew generateLicenseReport' locally and commit."
|
|
|
+ echo
|
|
|
+ echo "$(git diff --cached --stat licenses)"
|
|
|
+ echo
|
|
|
+ echo "$(git diff --cached licenses)"
|
|
|
+ exit 1
|
|
|
+ fi
|