Skip to content

Changed version and publish chart workflow #29

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

MarkBogelund
Copy link
Contributor

@MarkBogelund MarkBogelund commented May 22, 2025

The version in the helm chart created from the build_push_chart in do.sh now depends on the version specified in chart/CHart.yaml. This means that the version will only be specified in one place instead of both in the Chart.yaml and a proprietary VERSION file.

Also, the publish-chart.yml workflow has been updated, so it only runs when triggered manually or if the version has been bumped.


Summary by cubic

The chart version is now read directly from chart/Chart.yaml, and the publish-chart workflow only runs on manual trigger or when the chart version changes.

  • Refactors
    • Removed the separate VERSION file; version is now managed in one place.
    • Updated workflow to check for version changes before publishing.

Summary by CodeRabbit

  • Chores
    • Workflow can now be triggered manually and only runs publishing steps if the chart version changes.
    • Improved detection of chart version changes for more accurate workflow execution.
    • Updated script to extract chart version directly from the chart file instead of a separate version file.
    • Added prerequisite checks to ensure required tools and files are present before packaging and pushing the chart.

Copy link

coderabbitai bot commented May 22, 2025

📝 Walkthrough
## Walkthrough

The workflow for publishing a Helm chart was updated to allow manual triggering, restrict event monitoring to specific files, and introduce a new job to detect version changes in the chart. Additionally, the script responsible for building and pushing the chart now verifies prerequisites and extracts the version from the chart's YAML file using `yq` instead of reading from a separate version file.

## Changes

| File(s)                           | Change Summary                                                                                             |
|----------------------------------|-----------------------------------------------------------------------------------------------------------|
| .github/workflows/publish-chart.yml | Added `workflow_dispatch` manual trigger; restricted event paths to `chart/**` and workflow file; introduced `check-version-change` job to detect chart version changes; made `publish-chart` job conditional on version change or manual trigger; updated checkout step in both jobs to handle PR and push refs. |
| do.sh                            | Enhanced `build_push_chart` to check for `yq` and `chart/Chart.yaml` existence before proceeding; changed version extraction to use `yq` on `chart/Chart.yaml`; reformatted Helm push command for clarity. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant GitHub Actions
    participant check-version-change
    participant publish-chart

    User->>GitHub Actions: Push/PR to chart/** or manual trigger
    GitHub Actions->>check-version-change: Run job
    alt Manual trigger
        check-version-change->>publish-chart: Set changed=true
    else Version change detected
        check-version-change->>publish-chart: Set changed=true if version changed
    else No version change
        check-version-change->>publish-chart: Set changed=false
    end
    publish-chart-->>GitHub Actions: Run only if changed=true

</details>

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIgBhWExSeikKRHh8LEx6TwEvJFhGJIpcSAB3fAoAawAzL3xy0NiKtGQHAWZ1Gno5CNgSSGxESkgAWWdqgCF8Ui9sDHo2nm9ffyCQyAxHAVGAJgBOFCxcAb8SbnwMghcFDFxtcgowfyIkXBcAegGvZjAGEq4RBgfAMeBgXj4AAesg0MDOAOS0kgtVBw34WFgjX6gzSGSy8AwRH4tRxkAAEiRfsVnGVUMxMGgUuhFpAseUyYjSit8oVCcTKjV6tjUB94ERSP5aBojABlbiieC1eAMNA+WThU64yj4rDDGKEsmU6lcsoMfzUGJ9LWQATYeBeWgAfU8iFgTtNKIWYkyWENNto+A0bvs5vg3DKGGx/gKyMQ+GiXnkWTJeN99gVYOVBpOCMBn0StI0sjQzF8yuicPcyCp8C6GEtyBt5BiBEgDMJD39ZzTKf9lXsF2clp4XjQDGkgBQCG2F0rF0vlh2DHLoQfcYc0HgUfC8eAkB63ABqAFEbLKAJIAeQAciil9OBv4+hP7lQCgAvfmQXtYJivhMygYACCtC0OovpqkmmpnHkBRuv8gLFmWkAAOLqOS2ACJAQE+lkyCCnUDQckkMgkGQ7aKEqe70G2daQlIKBAhEFDipKX5/mB4h4VWZwEcKHLlA6vhRhyWRJn4CwVAMfp0sg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9i0AAAy0AAIwAGY4e1GRwAdgAGx7AEHD6H6OBAMGh8W6HWOAAcABWAQtBdhk5J6jvYDAscI8OoYQ7cOyfo9qCTuHZEBAABYEfQ5jrUWgtQyc07J4Tg4tRock7QHsNAZODgHBUOj3nAhodk+Z+DiAkBUfw5J8rkglPofK7J7UPYcPxyHDJ/DsnaA4d7Gh6jtABxocI+xyThHCO0BM7GhD1HqODh7F52gaH0PVAcLIib1HYe2fs41wwKJBw4eo4RyT2gCOA+i72Frw7JOJxh4OOj2gDOFcHHV9DhnIvEd68xwwVH0vBfw7QLLuHyvc8Q7d0odHCO8fh+LQr1HvPedU95xz2oVcTde9oJj9HDABCy4EMHrX2uoBfdwD9v7/gAd+zoE6CqzOgA=== -->

<!-- internal state end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=container-registry/helm-charts-oci-proxy&utm_content=29):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic found 2 issues across 2 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

if: github.event_name != 'workflow_dispatch' # Skip if manually triggered
run: |
if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then
PREVIOUS_VERSION=$(git show HEAD^:chart/Chart.yaml | grep 'version:' | awk '{print $2}')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Chart.yaml did not exist in the previous commit (e.g. the file was just added), git show HEAD^:chart/Chart.yaml returns a non-zero status which, together with set -eo pipefail used by GitHub runners, terminates the whole step and aborts the workflow. Guard the command or swallow the error so the version-check logic can proceed safely.

@@ -15,12 +15,11 @@ build_push_image() {
}

build_push_chart() {
version=$(cat VERSION)
version=$(yq -r '.version' chart/Chart.yaml)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The yq command is invoked with the -r flag but without the required sub-command (e|eval) that newer versions of mikefarah/yq expect; this exits with "unknown shorthand flag" and stops the build script (set -e).

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
.github/workflows/publish-chart.yml (1)

57-61: 🛠️ Refactor suggestion

Align checkout ref with version-check job
The check-version-change job uses:

ref: ${{ github.head_ref || github.ref_name }}

but the publish-chart job only uses github.head_ref. To cover both PRs and pushes, update it:

      - name: Checkout Code
        uses: actions/checkout@v3
        with:
-         ref: ${{ github.head_ref }}
+         ref: ${{ github.head_ref || github.ref_name }}
          fetch-depth: 0
🧰 Tools
🪛 actionlint (1.7.7)

58-58: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🧹 Nitpick comments (3)
.github/workflows/publish-chart.yml (3)

29-47: Use yq for robust YAML parsing in version check
Relying on grep and awk can break if Chart.yaml formatting changes. Since you already depend on yq, consider:

-   PREVIOUS_VERSION=$(git show HEAD^:chart/Chart.yaml | grep 'version:' | awk '{print $2}')
+   PREVIOUS_VERSION=$(git show HEAD^:chart/Chart.yaml | yq -r '.version')
-   CURRENT_VERSION=$(grep 'version:' chart/Chart.yaml | awk '{print $2}')
+   CURRENT_VERSION=$(yq -r '.version' chart/Chart.yaml)

This ensures consistent parsing.

🧰 Tools
🪛 actionlint (1.7.7)

31-31: shellcheck reported issue in this script: SC2086:info:7:28: Double quote to prevent globbing and word splitting

(shellcheck)


31-31: shellcheck reported issue in this script: SC2086:info:10:29: Double quote to prevent globbing and word splitting

(shellcheck)


31-31: shellcheck reported issue in this script: SC2086:info:14:27: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 YAMLlint (1.37.1)

[error] 35-35: trailing spaces

(trailing-spaces)


36-36: Remove trailing whitespace
This blank line contains trailing spaces and is flagged by YAML lint. Please delete the extra whitespace to satisfy the linter.


53-55: Simplify publish-chart job condition
Since the manual step already sets should_publish=true, the || github.event_name == 'workflow_dispatch' is redundant. You can streamline to:

if: needs.check-version-change.outputs.should_publish == 'true'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a32bb29 and e2d0d13.

📒 Files selected for processing (2)
  • .github/workflows/publish-chart.yml (1 hunks)
  • do.sh (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/publish-chart.yml

23-23: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


31-31: shellcheck reported issue in this script: SC2086:info:7:28: Double quote to prevent globbing and word splitting

(shellcheck)


31-31: shellcheck reported issue in this script: SC2086:info:10:29: Double quote to prevent globbing and word splitting

(shellcheck)


31-31: shellcheck reported issue in this script: SC2086:info:14:27: Double quote to prevent globbing and word splitting

(shellcheck)


50-50: shellcheck reported issue in this script: SC2086:info:1:24: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 YAMLlint (1.37.1)
.github/workflows/publish-chart.yml

[error] 35-35: trailing spaces

(trailing-spaces)

🔇 Additional comments (3)
.github/workflows/publish-chart.yml (3)

3-12: Restrict workflow triggers and enable manual dispatch
The on: section now scopes PR and push events to just chart/Chart.yaml and the workflow file, and adds workflow_dispatch for manual runs. This aligns perfectly with the goal of reducing unnecessary runs.


17-21: Expose version-change flag as a job output
Mapping steps.check-version.outputs.changed to outputs.should_publish makes downstream logic more readable.


49-51: Override version check for manual dispatch
The step correctly sets changed=true when workflow_dispatch is used, ensuring the chart is published on manual trigger.

🧰 Tools
🪛 actionlint (1.7.7)

50-50: shellcheck reported issue in this script: SC2086:info:1:24: Double quote to prevent globbing and word splitting

(shellcheck)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/publish-chart.yml (2)

37-37: Trim trailing whitespace
Line 37 contains trailing spaces which can break YAML linting.

Apply this diff to remove them:

-run: |
-              
+run: |
+   
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 37-37: trailing spaces

(trailing-spaces)


61-68: DRY up duplicated checkout configuration
The actions/checkout@v3 step is repeated in both jobs. Consider extracting it via a YAML anchor or a composite action to simplify maintenance and avoid drift.

🧰 Tools
🪛 actionlint (1.7.7)

65-65: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 156f81e and 7d189ae.

📒 Files selected for processing (1)
  • .github/workflows/publish-chart.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/publish-chart.yml

23-23: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


65-65: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/publish-chart.yml

[error] 37-37: trailing spaces

(trailing-spaces)

🔇 Additional comments (4)
.github/workflows/publish-chart.yml (4)

4-4: Enable manual triggering with workflow_dispatch
Adding workflow_dispatch allows on-demand chart publishes, which aligns well with the goal of manual runs.


7-8: Restrict triggers to relevant files only
Limiting pull_request and push paths to chart/Chart.yaml and the workflow file prevents unnecessary runs on unrelated changes.


17-27: Introduce version-change detection job
The new check-version-change job correctly checks out full history (fetch-depth: 0) and sets should_publish based on version diffs or manual dispatch. This cleanly isolates the publish condition.

🧰 Tools
🪛 actionlint (1.7.7)

23-23: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


54-58: Manual runs always trigger publication
The manual-flag step correctly sets changed=true for workflow_dispatch events, ensuring the publish-chart job executes as intended.

Comment on lines +31 to +33
run: |
if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then
# Check if Chart.yaml existed in previous commit
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid missing version changes on multi-commit pushes
Using git diff HEAD^ HEAD inspects only the last commit. If chart/Chart.yaml was modified earlier in a multi-commit push, this will be missed.

Switch to comparing the full push range provided by GitHub Actions:

- if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then
+ if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'chart/Chart.yaml'; then

This ensures all changes in the push are evaluated.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then
# Check if Chart.yaml existed in previous commit
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'chart/Chart.yaml'; then
# Check if Chart.yaml existed in previous commit
🤖 Prompt for AI Agents
In .github/workflows/publish-chart.yml around lines 31 to 33, the script uses
'git diff HEAD^ HEAD' which only checks the last commit for changes to
'chart/Chart.yaml', missing modifications in earlier commits of a multi-commit
push. Update the git diff command to use the full push range provided by GitHub
Actions, such as 'git diff ${{ github.event.before }} ${{ github.event.after
}}', to ensure all changes in the entire push are evaluated.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
.github/workflows/publish-chart.yml (1)

31-33: Avoid missing version changes on multi-commit pushes

Using git diff HEAD^ HEAD only inspects the last commit. In a multi-commit push, earlier changes to chart/Chart.yaml would be skipped.

Update the diff command to cover the full push range:

- if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then
+ if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q 'chart/Chart.yaml'; then
🧹 Nitpick comments (1)
.github/workflows/publish-chart.yml (1)

37-37: Remove trailing whitespace

There's a line with stray spaces that could cause YAML lint errors.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 37-37: trailing spaces

(trailing-spaces)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d189ae and 77924a0.

📒 Files selected for processing (1)
  • .github/workflows/publish-chart.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/publish-chart.yml

23-23: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


65-65: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 YAMLlint (1.37.1)
.github/workflows/publish-chart.yml

[error] 37-37: trailing spaces

(trailing-spaces)

🔇 Additional comments (5)
.github/workflows/publish-chart.yml (5)

4-8: Manual and path-trigger configuration looks good.

The addition of workflow_dispatch for manual runs and precise path filters for pull_request and push events correctly scopes the workflow to chart-related changes. This aligns with the PR objective to reduce unnecessary runs.

Also applies to: 11-12


17-27: check-version-change job configuration is sound.

The job initializes outputs, fetches the full commit history (fetch-depth: 0), and correctly determines the ref to checkout using ${{ github.head_ref || github.ref_name }}. This sets up the version-check logic robustly.

🧰 Tools
🪛 actionlint (1.7.7)

23-23: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


54-57: Manual-run flag step is correct.

The manual-flag step appropriately sets changed=true when workflow_dispatch is used. This ensures the publish job will run on manual triggers.


60-62: Conditional publish job gating is correct.

Requiring needs.check-version-change.outputs.should_publish == 'true' ensures the publish-chart job only executes when a version bump or manual trigger occurs.


67-68: Checkout ref expression is consistent.

Using ${{ github.head_ref || github.ref_name }} for both jobs ensures branches and PR contexts are handled uniformly.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/publish-chart.yml (1)

29-30: Update Git diff to cover entire push range
Using git diff HEAD^ HEAD only examines the last commit and can miss changes in multi-commit pushes. Switch to:

- if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then
+ if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'chart/Chart.yaml'; then

This aligns with GitHub’s full push range.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77924a0 and 8ce0096.

📒 Files selected for processing (1)
  • .github/workflows/publish-chart.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/publish-chart.yml

21-21: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


59-59: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (8)
.github/workflows/publish-chart.yml (8)

3-3: Enable manual triggering of the workflow
Adding workflow_dispatch is a great way to allow on-demand publishes without code changes.


6-7: Restrict PR triggers to chart and workflow file changes
Limiting pull_request events to chart/** and this workflow ensures you don’t run the chart-publish logic on unrelated changes.


10-11: Restrict push triggers to chart and workflow file changes on main
This mirrors the PR filter and keeps runs focused when chart/** or this workflow are updated.


15-18: Introduce check-version-change job with consolidated output
Good use of a dedicated job and a combined should_publish output to gate the publish step.


20-24: Use full clone and correct ref for both PRs and pushes
Fetching full history and using ${{ github.head_ref || github.ref_name }} covers PR branches as well as tag or branch builds.

🧰 Tools
🪛 actionlint (1.7.7)

21-21: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


26-29: Skip version diff logic on manual runs
The if: github.event_name != 'workflow_dispatch' guard cleanly separates manual versus automated checks.


50-53: Set publish flag on manual dispatch
Echoing changed=true for workflow_dispatch runs is clear and straightforward.


56-57: Conditional publish job based on version check
Gating publish-chart with needs.check-version-change.outputs.should_publish == 'true' cleanly prevents unnecessary publishes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/workflows/publish-chart.yml (1)

33-56: ⚠️ Potential issue

Use full push range for detecting version changes

The check git diff --name-only HEAD^ HEAD only inspects the last commit and can miss modifications in earlier commits of a multi-commit push. Switch to the full range provided by GitHub Actions:

- if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then
+ if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q 'chart/Chart.yaml'; then

This guarantees that all commits in the push are evaluated for version bumps.

🧹 Nitpick comments (1)
.github/workflows/publish-chart.yml (1)

26-31: Pin yq version to ensure reproducibility

Installing yq via the latest download link can introduce breaking changes unexpectedly. Consider pinning to a specific release, for example:

- sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
+ sudo wget https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64 -O /usr/local/bin/yq
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ce0096 and 03de636.

📒 Files selected for processing (1)
  • .github/workflows/publish-chart.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/publish-chart.yml

21-21: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


69-69: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (4)
.github/workflows/publish-chart.yml (4)

3-11: Approve workflow trigger updates

Supporting manual dispatch and restricting pull_request and push events to changes in chart/** and the workflow file reduces unnecessary runs and centralizes version bump checks.


15-19: Approve should_publish output expression

Combining the version-change and manual-flag outputs via
${{ steps.check-version.outputs.changed || steps.manual-flag.outputs.changed }}
correctly encapsulates the publish decision in one output.


23-24: Approve dynamic checkout ref usage

Using ref: ${{ github.head_ref || github.ref_name }} with fetch-depth: 0 ensures the workflow checks out the correct branch or PR head and retains full git history for diff operations.

Also applies to: 71-71


58-62: Approve manual publish flag

The manual-flag step correctly overrides the version check for workflow_dispatch events by setting changed=true, enabling manual publishes.

Comment on lines +64 to +65
needs: check-version-change
if: needs.check-version-change.outputs.should_publish == 'true'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Prevent publishing on pull_request events

As written, a version bump in a PR will trigger the publish-chart job and push artifacts for unmerged code. Restrict the publish step to pushes (e.g., on main) by extending the condition:

- if: needs.check-version-change.outputs.should_publish == 'true'
+ if: needs.check-version-change.outputs.should_publish == 'true' && github.event_name == 'push'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
needs: check-version-change
if: needs.check-version-change.outputs.should_publish == 'true'
needs: check-version-change
if: needs.check-version-change.outputs.should_publish == 'true' && github.event_name == 'push'
🤖 Prompt for AI Agents
In .github/workflows/publish-chart.yml at lines 64 to 65, the current condition
allows the publish-chart job to run on pull_request events, which can cause
unmerged code to be published. Modify the if condition to also check that the
event is a push event, for example by adding a condition to ensure
github.event_name == 'push' along with the existing should_publish check, so
publishing only occurs on pushes like to the main branch.

@MarkBogelund MarkBogelund marked this pull request as draft May 27, 2025 11:15
@MarkBogelund MarkBogelund marked this pull request as ready for review May 27, 2025 11:17
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic found 3 issues across 2 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

id: check-version
if: github.event_name != 'workflow_dispatch' # Skip if manually triggered
run: |
if git diff --name-only HEAD^ HEAD | grep -q 'chart/Chart.yaml'; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using HEAD^ assumes the previous commit exists; on the first commit of a branch or repository this command fails, causing the entire job to error out.

run: |
sudo apt-get update
sudo apt-get install -y jq
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary is downloaded and executed without any checksum or signature verification, exposing the build environment to potential supply-chain attacks if the URL is ever compromised.

echo "Error: chart/Chart.yaml not found." >&2
exit 1
fi
version=$(yq -r '.version' chart/Chart.yaml)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using yq without the "eval" (or "e") sub-command fails with modern versions of mikefarah/yq (v4+): running yq -r returns an unknown flag error, causing the script to exit. Use yq e -r (or yq eval -r) so the command works across common yq versions.

Suggested change
version=$(yq -r '.version' chart/Chart.yaml)
version=$(yq e -r '.version' chart/Chart.yaml)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant