github: workflows: Restore ok-package-test trigger behavior#11820
Conversation
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the PR package tests workflow to use label-gated ChangesPR Package Tests Workflow Hardening
🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/pr-package-tests.yaml (1)
42-61:⚠️ Potential issue | 🟠 Major | ⚡ Quick winLock down token permissions on reusable jobs under
pull_request_target.These
uses:jobs don't set explicitpermissions. Withpull_request_target, they inherit broaderGITHUB_TOKENscopes (repository-default dependent), which is risky when building PR-head code. Set least-privilege permissions per job (or at workflow level, then override only where needed).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/pr-package-tests.yaml around lines 42 - 61, The pr-container-builds job currently omits explicit permissions when invoked under pull_request_target, allowing the reusable job (uses: ./.github/workflows/call-build-images.yaml) to inherit broad GITHUB_TOKEN scopes; add a least-privilege permissions block to the job (e.g., explicitly set permissions: contents: read and packages: write or only the minimal scopes your reusable workflow needs) or set workflow-level permissions and override as necessary, ensuring the job’s inputs/secrets (version, ref, registry, token, cosign_private_key, etc.) still work but do not grant excess repository permissions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In @.github/workflows/pr-package-tests.yaml:
- Around line 42-61: The pr-container-builds job currently omits explicit
permissions when invoked under pull_request_target, allowing the reusable job
(uses: ./.github/workflows/call-build-images.yaml) to inherit broad GITHUB_TOKEN
scopes; add a least-privilege permissions block to the job (e.g., explicitly set
permissions: contents: read and packages: write or only the minimal scopes your
reusable workflow needs) or set workflow-level permissions and override as
necessary, ensuring the job’s inputs/secrets (version, ref, registry, token,
cosign_private_key, etc.) still work but do not grant excess repository
permissions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 16a17642-6bff-4afc-aa75-27290957cbb5
📒 Files selected for processing (1)
.github/workflows/pr-package-tests.yaml
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
On this patch,
ok-package-testworks as the maintainer-controlled switch for the full package workflow.When someone adds the
ok-package-testlabel to a PR, GitHub fires thepull_request_targetworkflow from the base repository. The first job checks two things before anything expensive runs:So the workflow only proceeds when the label is present, and only for same-repository PR branches. That restores the label-triggered behavior while avoiding privileged execution for fork-controlled code.
The actual build jobs then pass:
to the reusable Linux, Windows, macOS, and container build workflows. That detail matters: because
pull_request_targetruns in the base-repo context,github.refwould point at the target/base side, not the PR code. Using the PR head SHA makes the package builders check out and build the exact commit from the labeled PR.Finally, the concurrency group is now:
${{ github.workflow }}-${{ github.event.pull_request.number }}so reruns or new commits for the same PR cancel older package runs for that PR, but package builds for different PRs no longer cancel each other just because they all target
master.Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit