2024-01-04 20:17:38 +01:00
|
|
|
name: License Report Workflow
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
paths:
|
2024-04-21 17:30:17 +02:00
|
|
|
- "build.gradle"
|
2024-01-04 20:17:38 +01:00
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
pull-requests: write
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
generate-license-report:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Check out code
|
2024-04-21 17:30:17 +02:00
|
|
|
uses: actions/checkout@v4
|
2024-01-04 20:17:38 +01:00
|
|
|
|
|
|
|
- name: Set up JDK 17
|
2024-04-21 17:30:17 +02:00
|
|
|
uses: actions/setup-java@v4
|
2024-01-04 20:17:38 +01:00
|
|
|
with:
|
2024-04-21 17:30:17 +02:00
|
|
|
java-version: "17"
|
|
|
|
distribution: "adopt"
|
|
|
|
|
2024-08-18 14:07:14 +02:00
|
|
|
- uses: gradle/actions/setup-gradle@v4
|
2024-01-04 20:17:38 +01:00
|
|
|
|
|
|
|
- name: Run Gradle Command
|
|
|
|
run: ./gradlew clean generateLicenseReport
|
|
|
|
|
|
|
|
- name: Move and Rename License File
|
|
|
|
run: |
|
|
|
|
mv build/reports/dependency-license/index.json src/main/resources/static/3rdPartyLicenses.json
|
|
|
|
|
2024-03-13 23:26:39 +01:00
|
|
|
- name: Set up git config
|
2024-01-04 21:59:52 +01:00
|
|
|
run: |
|
2024-03-13 23:26:39 +01:00
|
|
|
git config --global user.email "GitHub Action <action@github.com>"
|
|
|
|
git config --global user.name "GitHub Action <action@github.com>"
|
2024-01-04 21:59:52 +01:00
|
|
|
|
2024-03-13 23:26:39 +01:00
|
|
|
- name: Run git add
|
2024-01-04 20:17:38 +01:00
|
|
|
run: |
|
2024-03-13 23:26:39 +01:00
|
|
|
git add src/main/resources/static/3rdPartyLicenses.json
|
2024-03-13 23:34:24 +01:00
|
|
|
git diff --staged --quiet || echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
|
2024-03-13 23:26:39 +01:00
|
|
|
|
|
|
|
- name: Create Pull Request
|
2024-08-16 13:15:07 +02:00
|
|
|
id: cpr
|
2024-03-13 23:26:39 +01:00
|
|
|
if: env.CHANGES_DETECTED == 'true'
|
2024-04-21 17:30:17 +02:00
|
|
|
uses: peter-evans/create-pull-request@v6
|
2024-03-13 23:26:39 +01:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
commit-message: "Update 3rd Party Licenses"
|
|
|
|
committer: GitHub Action <action@github.com>
|
|
|
|
author: GitHub Action <action@github.com>
|
|
|
|
signoff: true
|
|
|
|
branch: update-3rd-party-licenses
|
|
|
|
title: "Update 3rd Party Licenses"
|
|
|
|
body: |
|
|
|
|
Auto-generated by [create-pull-request][1]
|
2024-08-18 14:07:14 +02:00
|
|
|
|
2024-03-13 23:26:39 +01:00
|
|
|
[1]: https://github.com/peter-evans/create-pull-request
|
2024-08-16 12:00:10 +02:00
|
|
|
labels: licenses
|
2024-03-13 23:26:39 +01:00
|
|
|
draft: false
|
|
|
|
delete-branch: true
|
2024-08-16 12:00:10 +02:00
|
|
|
|
2024-08-16 13:15:07 +02:00
|
|
|
- name: Auto approve
|
|
|
|
if: steps.cpr.outputs.pull-request-operation == 'created'
|
|
|
|
run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}"
|
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2024-08-18 14:07:14 +02:00
|
|
|
|
2024-08-16 12:00:10 +02:00
|
|
|
- name: Enable auto-merge
|
2024-08-16 13:15:07 +02:00
|
|
|
if: steps.cpr.outputs.pull-request-operation == 'created'
|
|
|
|
uses: peter-evans/enable-pull-request-automerge@v3
|
2024-08-16 12:00:10 +02:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2024-08-16 13:15:07 +02:00
|
|
|
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
|
2024-08-16 12:00:10 +02:00
|
|
|
merge-method: squash # Choose the merge method: merge, squash, or rebase
|