From 523ed62ce9ce350cbc91ed881a3be172d792f9dd Mon Sep 17 00:00:00 2001 From: Vincenzo Pierro Date: Thu, 7 Nov 2024 09:27:26 +0100 Subject: [PATCH] Added license report probe --- .github/workflows/license-report.yaml | 55 +++++++++++++++++++++++++++ build.gradle.kts | 9 ++++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/license-report.yaml diff --git a/.github/workflows/license-report.yaml b/.github/workflows/license-report.yaml new file mode 100644 index 0000000..0cf1a56 --- /dev/null +++ b/.github/workflows/license-report.yaml @@ -0,0 +1,55 @@ +on: + pull_request: + types: + - closed + branches: + - 'main' + +jobs: + licenses_report: + name: Generating licenses report + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: Setup JDK + uses: actions/setup-java@v2 + with: + java-version: '21' + distribution: 'adopt' + + - name: Creating licenses report + env: + ORG_GRADLE_PROJECT_repoUsername: ${{ secrets.REPO_USERNAME }} + ORG_GRADLE_PROJECT_repoPassword: ${{ secrets.REPO_PASSWORD }} + run: ./gradlew generateLicenseReport -x build + + - name: Copy, rename, and remove header + run: tail -n +2 ./build/reports/dependency-license/licenses.csv > ./${{ github.event.repository.name }}.csv + + - name: Setup Git + run: | + git config --global user.name "icure-dev" + git config --global user.email "dev@icure.com" + + - name: Setup SSH Keys and known_hosts + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${{ secrets.REPO_DEPLOY_KEY }}" + + - name: Publish file to licenses-report + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + run: | + git clone git@github.com:icure/licenses-report.git + cd licenses-report + mv ../${{ github.event.repository.name }}.csv ./java_kotlin/${{ github.event.repository.name }}.csv + git add ./java_kotlin/${{ github.event.repository.name }}.csv + STATUS=$(git status --porcelain) + if [ -n "$STATUS" ]; then + git commit -m "Update ${{ github.event.repository.name }}.csv" + git push + fi diff --git a/build.gradle.kts b/build.gradle.kts index c9a5031..3d48f8a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,18 @@ +import com.github.jk1.license.render.CsvReportRenderer +import com.github.jk1.license.render.ReportRenderer + plugins { kotlin("jvm") version "1.9.21" kotlin("plugin.serialization") version "1.9.21" id("com.github.johnrengelman.shadow") version "7.1.2" - + id("com.github.jk1.dependency-license-report") version "2.0" application } +licenseReport { + renderers = arrayOf(CsvReportRenderer()) +} + buildscript { dependencies { classpath("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")