Skip to content

Conversation

@rawagner
Copy link
Contributor

@rawagner rawagner commented Nov 12, 2025

Summary by Sourcery

Add a GitHub Actions workflow that generates versioned tags and builds plus pushes the Koku UI OnPrem container image to Quay.io when changes are pushed to the main branch or onprem-* tags.

CI:

  • Add GitHub Actions workflow to build and publish onprem UI container on pushes to main and onprem-* tags
  • Generate dynamic image tags based on git refs or commit SHA
  • Use Buildah to build and push the container to Quay.io with appropriate labels and credentials

@rawagner rawagner requested a review from a team as a code owner November 12, 2025 16:05
@gemini-code-assist
Copy link
Contributor

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 12, 2025

Reviewer's Guide

This PR introduces a new GitHub Actions workflow to generate dynamic image tags based on git refs and automate building and publishing the Koku UI OnPrem container images to Quay.io when changes are pushed to the main branch or onprem-* tags.

Flow diagram for dynamic image tag generation and publishing

flowchart TD
  A["Push to main branch or onprem-* tag"] --> B["generate-tags job"]
  B -->|"If ref is tag"| C["Set image tag to release tag (without 'v' prefix)"]
  B -->|"If ref is not tag"| D["Set image tags to latest-SHA, latest, and version (without 'v' prefix)"]
  C & D --> E["publish-onprem-ui job"]
  E --> F["Build container image"]
  F --> G["Push image to Quay.io"]
Loading

File-Level Changes

Change Details Files
Define new GitHub Actions workflow for onprem UI publishing
  • Add .github/workflows/koku-ui-onprem-push-main.yml
  • Configure push triggers for main branch and onprem-* tags
  • Set QUAY_ORG and QUAY_UI_REPO environment variables
.github/workflows/koku-ui-onprem-push-main.yml
Implement tag generation logic
  • Use actions/checkout with fetch-depth 0 and fetch-tags
  • Add conditional script to derive image_tags from git tags or commit SHA
  • Expose image_tags output for downstream jobs
.github/workflows/koku-ui-onprem-push-main.yml
Setup build and push jobs
  • Add build step using redhat-actions/buildah-build with custom labels and ulimit settings
  • Configure push step using redhat-actions/push-to-registry with Quay credentials
.github/workflows/koku-ui-onprem-push-main.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-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.

Hey there - I've reviewed your changes - here's some feedback:

  • The shell conditional for github.ref_type inside the run block won’t work as written—move that check to a step-level “if: github.ref_type == 'tag'” or use a proper shell test on GITHUB_REF.
  • You’re filtering tags with onprem-* but then only stripping a leading “v”; make sure your version extraction logic matches your actual tag naming convention or adjust the prefix removal accordingly.
  • Consider adding a concurrency group to the workflow or job to prevent overlapping builds when multiple commits or tags land on main in quick succession.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The shell conditional for github.ref_type inside the run block won’t work as written—move that check to a step-level “if: github.ref_type == 'tag'” or use a proper shell test on GITHUB_REF.
- You’re filtering tags with onprem-* but then only stripping a leading “v”; make sure your version extraction logic matches your actual tag naming convention or adjust the prefix removal accordingly.
- Consider adding a concurrency group to the workflow or job to prevent overlapping builds when multiple commits or tags land on main in quick succession.

## Individual Comments

### Comment 1
<location> `.github/workflows/koku-ui-onprem-push-main.yml:36-41` </location>
<code_context>
+            echo "image_tags=${image_tags[@]}"
+
+          else
+            version=$(git describe --long --tags --exclude latest)
+            version=${version#v} # remove the leading v prefix for version
+            # The images tags are taken from git
+            image_tags=( latest-${GITHUB_SHA} latest ${version} )
+            echo "image_tags=${image_tags[@]}" >> $GITHUB_OUTPUT
+            echo "image_tags=${image_tags[@]}"
</code_context>

<issue_to_address>
**suggestion:** Potential for 'git describe' to fail if no tags are present.

Add error handling or a fallback value for cases where 'git describe' fails due to missing tags to prevent workflow errors.

```suggestion
            # Try to get version from git describe, fallback to untagged-SHA if no tags exist
            if version=$(git describe --long --tags --exclude latest 2>/dev/null); then
              version=${version#v} # remove the leading v prefix for version
            else
              version="untagged-${GITHUB_SHA}"
            fi
            # The images tags are taken from git
            image_tags=( latest-${GITHUB_SHA} latest ${version} )
            echo "image_tags=${image_tags[@]}" >> $GITHUB_OUTPUT
            echo "image_tags=${image_tags[@]}"
```
</issue_to_address>

### Comment 2
<location> `.github/workflows/koku-ui-onprem-push-main.yml:73` </location>
<code_context>
+        with:
+          image: ${{ steps.build.outputs.image }}
+          tags: ${{ needs.generate-tags.outputs.image_tags }}
+          registry: ${{ env.QUAY_ORG }}
+          username: ${{ secrets.QUAY_INSIGHTS_ONPREM_ROBOT_USERNAME }}
+          password: ${{ secrets.QUAY_INSIGHTS_ONPREM_ROBOT_PASSWORD }}
</code_context>

<issue_to_address>
**issue (bug_risk):** Registry variable includes trailing slash, which may cause issues with some tools.

Ensure that QUAY_ORG does not include a trailing slash to avoid compatibility issues with registry tools during the push-to-registry action.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.07%. Comparing base (e866eb9) to head (0b4c7d2).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4616   +/-   ##
=======================================
  Coverage   87.07%   87.07%           
=======================================
  Files         480      480           
  Lines        9078     9078           
  Branches     2198     2195    -3     
=======================================
  Hits         7905     7905           
  Misses       1107     1107           
  Partials       66       66           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

on:
push:
branches:
- main
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to run this for a branch other than main (e.g., stage-onprem)?

I modified our Konflux builds to run only when pushing to stage-hccm and prod-hccm, for example. The CI workflow still builds and tests all apps, but quay images are not created for unrelated changes. I imagine build times would be shorter, too.

Copy link
Contributor Author

@rawagner rawagner Nov 14, 2025

Choose a reason for hiding this comment

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

onprem generally doesnt have any stage environment. You can either run the latest (IOW main), or from a release branch.
Having a stage branch is a big hassle -> you need to closely follow all changes to common libs/other places that may affect you and do the backports. Unless we have a very good reason for stage - and in onprem we don't - i'd like to avoid it.

Im not sure how build times would get shorter. This build & push job runs after push to main branch, it should not block/slow down anything .. ?

Copy link
Contributor

@dlabrecq dlabrecq Nov 14, 2025

Choose a reason for hiding this comment

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

I probably misunderstood how this works. Does this workflow run for every push to main or is it triggered with a tag? If it's by tag only, then no worries. Seems like it's both, tho?

Our stage and prod branches are simply used to generate quay images. (We also need the unique SHA as a ref when deploying to app-interface.) There's no back porting here, no merge conflicts, etc. -- we're just merging the latest copy of main. However, by pushing to these branches, it triggers Konflux to generate quay images.

A branch is an extra step; however, changes to koku-ui-hccm probably shouldn't automatically deploy koku-ui-onprem and vice versa.

Copy link
Contributor Author

@rawagner rawagner Nov 18, 2025

Choose a reason for hiding this comment

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

You understood it correctly, we would build & push on every push to main (which would result to quay.io/insights-onprem/koku-ui-onprem:latest), and on every tag (quay.io/insights-onprem/koku-ui-onprem:<tag>).

I'd honestly prefer to have more quay images, than doing a manual merge to stage branch - to get latest builds to QE faster & not require merge to stage branch.
We do not have any issue with things slowing down right now - it seems like we are doing a premature optimization here and just pushing more work on us.
If we notice there is an issue this approach, i'd be happy to change it.

However, if you still feel we need to use the stage branch here from the beginning, i'll change it. Just wanted to lay my case here :)

Copy link
Contributor Author

@rawagner rawagner Nov 18, 2025

Choose a reason for hiding this comment

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

I've updated the job definition - it does not run on push to main if /apps/<saas_app> changed, for other changes it does. I didnt try this approach yet, so unsure how well it will work, but I guess this could be worth trying.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi. I spoke with the team and the consensus was "no crossover". Cost/ROS updates (libs, dependencies, etc.) shouldn't automatically publish onprem. Although, we can revisit the onprem releases later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. Thanks for following up on this.
I've updated the branch trigger to stage-onprem (and also tag)

@dlabrecq dlabrecq force-pushed the main branch 6 times, most recently from 04368d9 to 4e35c2c Compare November 19, 2025 20:25
@rawagner rawagner changed the title onprem - Setup publishing job after push to main onprem - Setup publishing job after push to stage Nov 20, 2025
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.

2 participants