Github has a native tool to obtain the PR diff.
This also resolves a warning from the action log:
2026-07-30T16:02:20.3415885Z Node 20 is being deprecated. This workflow is running with Node 24 by default. If you need to temporarily use Node 20, you can set the ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true environment variable. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
name: "Check for Incompatible Licenses"
runs-on: ubuntu-latest
steps:
- - name: Check Pull Request
- uses: JJ/github-pr-contains-action@526dfe784d8604ea1c39b6c26609074de95b1ffd # releases/v14.1
- with:
- github-token: ${{github.token}}
- diffDoesNotContain: "GNU General Public License"
+ - name: Check PR Diff for License
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ DIFF=$(gh pr diff ${{ github.event.pull_request.number }} -R ${{ github.repository }})
+ if echo "$DIFF" | grep -qi "GNU General Public License"; then
+ echo "Error: Incompatible license 'GNU General Public License' found in PR diff."
+ exit 1
+ fi