chore: remove publish images for release branches in cli worklfow#1962
Conversation
…for controller. Simplify check for push eligibility. On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughUpdated two GitHub Actions workflows: CLI workflow adds release branch/tag push triggers and simplifies push eligibility; Kubernetes controller workflow removes manual dispatch and consolidates publish eligibility into a single ref-pattern check. Release branches run build/test only; publishing remains tied to main or release tags. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.OpenGrep is compatible with Semgrep configurations. Add an |
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 (2)
.github/workflows/kubernetes-controller.yml (1)
158-173:⚠️ Potential issue | 🔴 CriticalExclude PR events from the publish eligibility check.
On
pull_requestevents,REFresolves togithub.head_ref(Line 52). A PR branch namedkubernetes/controller/v1.2.3will match the version regex here and setshould_publish=true, allowing thepublishjob (Line 295) to run on unmerged PR code. Add a guard condition to skip this check for PRs, as the CLI workflow already does.Suggested fix
- name: Determine publish eligibility + if: ${{ github.event_name != 'pull_request' }} id: branch-check uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 env: REF: ${{ env.REF }} with: script: | const ref = process.env.REF; const defaultBranch = context.payload.repository?.default_branch || 'main'; // Publish for: main or release tags. // Release branches (releases/v*) only build+test. core.setOutput( 'should_publish', ref === defaultBranch || /^kubernetes\/controller\/v\d+\.\d+(\.\d+)?(-.*)?$/.test(ref) );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/kubernetes-controller.yml around lines 158 - 173, The branch-check step (id: branch-check) sets the output should_publish based only on REF and a version-regex, which causes pull_request events (where REF is github.head_ref) to incorrectly mark PR branches like kubernetes/controller/v1.2.3 as publishable; update the script to first detect the event type (e.g., context.eventName or github.event_name) and short-circuit so that when the event is "pull_request" it sets should_publish to false (or skips the regex check), otherwise proceed with the existing defaultBranch/ref vs /^kubernetes\/controller\/v\d+\.\d+(\.\d+)?(-.*)?$/ test — modify the branch-check step to include this guard so publish cannot run on unmerged PR code..github/workflows/cli.yml (1)
124-133:⚠️ Potential issue | 🟠 MajorUse the ref being built when deciding publish eligibility.
This step checks
GITHUB_REF_NAME, but the workflow otherwise builds fromenv.REF(Lines 48 and 77). Underworkflow_call, a caller can overrideref; with the current code, the publish decision is made from the GitHub context ref instead of the actual ref being built. Reuseenv.REFhere for consistency.Suggested fix
- name: Determine if this is a push-eligible branch if: ${{ github.event_name != 'pull_request' }} id: branch-check uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + env: + REF: ${{ env.REF }} with: script: | + const ref = process.env.REF; core.setOutput( "should_push_oci_image", - process.env.GITHUB_REF_NAME === context.payload.repository.default_branch || - /^cli\/v\d+\.\d+(\.\d+)?(-.*)?$/.test(process.env.GITHUB_REF_NAME) + ref === context.payload.repository.default_branch || + /^cli\/v\d+\.\d+(\.\d+)?(-.*)?$/.test(ref) )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/cli.yml around lines 124 - 133, The publish eligibility check in the GitHub Action step with id "branch-check" uses process.env.GITHUB_REF_NAME but the workflow builds from env.REF when callers can override the ref; update the script used by actions/github-script (the core.setOutput call that sets "should_push_oci_image") to use process.env.REF instead of process.env.GITHUB_REF_NAME while keeping the existing comparison against context.payload.repository.default_branch and the /^cli\/v\d+\.\d+(\.\d+)?(-.*)?$/ regex so the decision reflects the actual ref being built.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In @.github/workflows/cli.yml:
- Around line 124-133: The publish eligibility check in the GitHub Action step
with id "branch-check" uses process.env.GITHUB_REF_NAME but the workflow builds
from env.REF when callers can override the ref; update the script used by
actions/github-script (the core.setOutput call that sets
"should_push_oci_image") to use process.env.REF instead of
process.env.GITHUB_REF_NAME while keeping the existing comparison against
context.payload.repository.default_branch and the
/^cli\/v\d+\.\d+(\.\d+)?(-.*)?$/ regex so the decision reflects the actual ref
being built.
In @.github/workflows/kubernetes-controller.yml:
- Around line 158-173: The branch-check step (id: branch-check) sets the output
should_publish based only on REF and a version-regex, which causes pull_request
events (where REF is github.head_ref) to incorrectly mark PR branches like
kubernetes/controller/v1.2.3 as publishable; update the script to first detect
the event type (e.g., context.eventName or github.event_name) and short-circuit
so that when the event is "pull_request" it sets should_publish to false (or
skips the regex check), otherwise proceed with the existing defaultBranch/ref vs
/^kubernetes\/controller\/v\d+\.\d+(\.\d+)?(-.*)?$/ test — modify the
branch-check step to include this guard so publish cannot run on unmerged PR
code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ea39c312-a9cb-4b21-b777-d9e7c6f096f2
📒 Files selected for processing (2)
.github/workflows/cli.yml.github/workflows/kubernetes-controller.yml
|
why? tickets? Can you please link or document your mental model in issues please? |
Came up in the war room. Is part of open-component-model/ocm-project#863. I added it. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/kubernetes-controller.yml:
- Around line 4-6: Update the header comment in the Kubernetes workflow to stop
implying tag-triggered runs: remove or rephrase the phrase "as well as release
tags" and explicitly state that the workflow triggers on pushes to main or
release branches and on PRs targeting main or release branches, and that tag
pushes (i.e. on.push.tags) are not defined so tags do not directly trigger this
workflow; ensure the comment references that release branches (e.g.
releases/v**) run builds and e2e tests but tags are not configured as triggers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9a1f9811-2536-40f1-a694-b9de78cd9e6e
📒 Files selected for processing (1)
.github/workflows/kubernetes-controller.yml
…release-branches On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
…i-son/open-component-model into remove-publish-for-release-branches On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
On-behalf-of: Gerald Morrison (SAP) gerald.morrison@sap.com
What this PR does / why we need it
Summary by CodeRabbit