ci: validate-pr: validate commit messages through GitHub API - #53327
Merged
Conversation
thaJeztah
force-pushed
the
improve_commit_checks
branch
2 times, most recently
from
August 7, 2026 11:46
193b6d3 to
ea73f3d
Compare
thaJeztah
force-pushed
the
improve_commit_checks
branch
from
August 7, 2026 11:58
d2a2eaf to
51efc68
Compare
thaJeztah
marked this pull request as ready for review
August 7, 2026 12:12
There was a problem hiding this comment.
Pull request overview
This workflow update makes the validate-pr CI check validate PR commit messages via the GitHub Pull Request Commits API (using gh api) instead of checking out the repository and scanning local git history. This reduces runtime and avoids executing scripts from untrusted PR checkouts.
Changes:
- Replace repository checkout +
hack/validate/pr-gh-referencesexecution withgh apifetching PR commits andjq-based validation. - Update workflow token permissions to
pull-requests: read. - Improve log output by printing a success message including the number of commits checked.
Use the pull request commits API to validate commit messages instead of
checking out the repository and inspecting the local Git history.
This avoids fetching the repository solely for commit metadata, making the
check lighter and faster. It also avoids executing validation scripts from
the PR checkout, reducing exposure to untrusted PR-controlled code.
While updating; also touched-up the messages slightly, and added a log
for successful checks (to verify the expected number of commits were
checked).
Before this patch, the check took 20-30 seconds; with this patch it's
1-2 seconds.
Failing check:
Run Check GitHub references
Run gh api --paginate --slurp "/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/commits" > "$RUNNER_TEMP/pr-commits.json"
Error: commit ea73f3d contains a GitHub issue or PR reference; use a commit hash instead if a reference is needed.
Remove GitHub issue or PR references from commit messages.
Use commit hashes instead if a reference is needed.
Keep GitHub issue or PR references in GitHub-visible text, such as PR descriptions or comments.
Error: Process completed with exit code 1.
Successful check:
Run Check GitHub references
Run gh api --paginate --slurp "/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/commits" > "$RUNNER_TEMP/pr-commits.json"
Checked 3 commit(s); no GitHub issue or PR references found.
Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah
force-pushed
the
improve_commit_checks
branch
from
August 7, 2026 13:32
51efc68 to
caea3b4
Compare
vvoland
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ci: validate-pr: validate commit messages through GitHub API
Use the pull request commits API to validate commit messages instead of
checking out the repository and inspecting the local Git history.
This avoids fetching the repository solely for commit metadata, making the
check lighter and faster. It also avoids executing validation scripts from
the PR checkout, reducing exposure to untrusted PR-controlled code.
While updating; also touched-up the messages slightly, and added a log
for successful checks (to verify the expected number of commits were
checked).
Before this patch, the check took 20-30 seconds; with this patch it's
1-2 seconds.
Failing check:
Successful check:
Before:
After:
Release notes (optional)
A picture of a cute animal (not mandatory but encouraged)