| # |
| # Copyright (c) 2022, 2026 Contributors to the Eclipse Foundation |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License v. 2.0 which is available at |
| # http://www.eclipse.org/legal/epl-2.0, |
| # or the Eclipse Distribution License v. 1.0 which is available at |
| # http://www.eclipse.org/org/documents/edl-v10.php. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause |
| # |
| name: License Check |
| on: |
| workflow_dispatch: |
| schedule: |
| - cron: "0 5 * * *" |
| issue_comment: |
| types: [created] |
| permissions: |
| contents: read |
| pull-requests: write |
| jobs: |
| build: |
| if: > |
| github.event_name != 'issue_comment' || |
| (github.event.issue.pull_request && |
| contains(github.event.comment.body, '/check-license') || |
| contains(github.event.comment.body, '/license-check') |
| ) |
| name: Build on JDK ${{ matrix.java_version }} with ${{matrix.test_profiles}} profile |
| runs-on: ubuntu-latest |
| env: |
| script-directory: $GITHUB_WORKSPACE/etc/jenkins |
| strategy: |
| matrix: |
| java_version: [ 11 ] |
| verify_profiles: [ '-Plicense_check' ] |
| steps: |
| - name: Get PR ref |
| if: github.event_name == 'issue_comment' |
| id: pr |
| uses: actions/github-script@v7 |
| with: |
| script: | |
| const pr = await github.rest.pulls.get({ |
| owner: context.repo.owner, |
| repo: context.repo.repo, |
| pull_number: context.issue.number |
| }); |
| core.setOutput('ref', pr.data.head.sha); |
| - name: Checkout for build |
| uses: actions/checkout@v4 |
| with: |
| fetch-depth: 0 |
| ref: ${{ steps.pr.outputs.ref || github.ref }} |
| - name: Set up JDK |
| uses: actions/setup-java@v4.1.0 |
| with: |
| distribution: 'temurin' |
| java-version: ${{ matrix.java_version }} |
| - name: Build |
| id: license-check |
| run: mvn -ntp -V -U -B ${{matrix.verify_profiles}} org.eclipse.dash:license-tool-plugin:license-check -DexcludeArtifactIds=bsh,jmh-core,jmh-generator-annprocess,swing-layout |
| continue-on-error: true |
| - name: Upload license-check info |
| uses: actions/upload-artifact@v4 |
| with: |
| name: license-summary.txt |
| path: target/dash/summary |
| - name: Post license summary to PR |
| if: github.event_name == 'issue_comment' |
| uses: actions/github-script@v7 |
| with: |
| script: | |
| const fs = require('fs'); |
| const path = 'target/dash/summary'; |
| let body = '### 📋 Eclipse License Check\n\n'; |
| if (fs.existsSync(path)) { |
| const content = fs.readFileSync(path, 'utf8').slice(0, 60000); |
| const status = '${{ steps.license-check.outcome }}' === 'success' ? '✅ Passed' : '⚠️ Issues found (non-blocking) — see the run log for details'; |
| body += `**Status:** ${status}\n\n<details><summary>Full summary</summary>\n\n\`\`\`\n${content}\n\`\`\`\n</details>`; |
| } else { |
| const status = '${{ steps.license-check.outcome }}' === 'success' ? '✅ Passed' : '⚠️ Failed (non-blocking) — no summary file produced, check the run log'; |
| body += `**Status:** ${status}`; |
| } |
| const { data: comments } = await github.rest.issues.listComments({ |
| owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number |
| }); |
| const existing = comments.find(c => c.body.startsWith('### 📋 Eclipse License Check')); |
| if (existing) { |
| await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: existing.id, body }); |
| } else { |
| await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body }); |
| } |