-
Notifications
You must be signed in to change notification settings - Fork 11
have fetch_licenses workflow only update when new licenses not already in the PR #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the fetch-licenses workflow to compare changes against the PR branch (if it exists) instead of always comparing against the main branch. This prevents noisy daily updates to an existing PR when there are no actual license changes.
Changes:
- Added a step to determine the baseline branch (auto-update-licenses if PR exists, otherwise main)
- Updated git diff commands to compare against the determined baseline branch instead of the working directory
- Fixed a debug output command to correctly display the current branch name
Comments suppressed due to low confidence (1)
.github/workflows/fetch-licenses.yaml:90
- The git diff command is comparing against a remote branch reference (origin/auto-update-licenses or origin/main), but the workflow only performs a checkout without fetching the remote branch first. When actions/checkout@v6 runs, it only fetches the current branch by default. This means that origin/auto-update-licenses may not be available locally for the diff command to use, which could cause the diff to fail or behave unexpectedly. Consider adding a fetch step after determining the baseline branch, or ensure that the baseline branch is fetched before performing the diff operations.
git diff --quiet "$BASE_REF" -- spdxexp/spdxlicenses/*.go && genfiles_changed=false
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo "Update Licenses PR exists, so diff against its branch origin/auto-update-licenses." | ||
| base_ref="origin/auto-update-licenses" | ||
| else | ||
| echo "Update Licenses PR does NOT exists, so diff against branch origin/main" |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a grammatical error in this echo message. The word "exists" should be singular here, not "does NOT exists". It should be "does NOT exist".
| echo "Update Licenses PR does NOT exists, so diff against branch origin/main" | |
| echo "Update Licenses PR does NOT exist, so diff against branch origin/main" |
| src_changed=true | ||
| # --quiet: Exits with 1 if there are changes; otherwise, exits with 0 | ||
| git diff --quiet -- cmd/licenses.json cmd/exceptions.json && src_changed=false | ||
| git diff --quiet "$BASE_REF" -- cmd/licenses.json cmd/exceptions.json && src_changed=false |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The git diff command is comparing against a remote branch reference (origin/auto-update-licenses or origin/main), but the workflow only performs a checkout without fetching the remote branch first. When actions/checkout@v6 runs, it only fetches the current branch by default. This means that origin/auto-update-licenses may not be available locally for the diff command to use, which could cause the diff to fail or behave unexpectedly. Consider adding a fetch step after determining the baseline branch, or ensure that the baseline branch is fetched before performing the diff operations.
This issue also appears in the following locations of the same file:
- line 90
Context
Fixes #126
Changes
Updates the workflow that runs nightly to update licenses to compare changes to the PR's branch if it exists and the main branch if it doesn't. This should eliminate the noisy comments in the PR's timeline that happen daily once the PR is created. It is more meaningful to only see changes when there are new licenses. It provides information on how often the licenses are actually changing.