Skip to content

Add attended script for multi-branch UBI bump PRs#3430

Open
simonbaird wants to merge 1 commit into
conforma:mainfrom
simonbaird:ubi-bump-automation
Open

Add attended script for multi-branch UBI bump PRs#3430
simonbaird wants to merge 1 commit into
conforma:mainfrom
simonbaird:ubi-bump-automation

Conversation

@simonbaird

Copy link
Copy Markdown
Member

Summary

  • Adds hack/ubi-bump-prs.sh, an attended script that creates UBI base image bump PRs across all active release branches
  • Wraps hack/ubi-base-image-bump.sh and adds RPM version diffing (via podman run rpm -qa) in both the commit message and PR body
  • Prompts for confirmation before creating each PR

Usage

hack/ubi-bump-prs.sh                        # all default branches
hack/ubi-bump-prs.sh main                   # specific branch(es)
hack/ubi-bump-prs.sh release-v0.8 main      # multiple specific branches

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 947460b1-741c-43e4-862f-3f38267a3cd4

📥 Commits

Reviewing files that changed from the base of the PR and between c48f604 and a3090fb.

📒 Files selected for processing (1)
  • hack/ubi-bump-prs.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • hack/ubi-bump-prs.sh

📝 Walkthrough

Walkthrough

The new hack/ubi-bump-prs.sh script validates prerequisites, discovers the latest UBI digest, updates configured release branches, compares RPM inventories, and interactively creates commits and pull requests.

Changes

UBI bump pull request automation

Layer / File(s) Summary
Preflight and branch updates
hack/ubi-bump-prs.sh
Configures branches and remotes, validates required tools and repository state, fetches upstream, resolves the latest UBI digest, and runs the existing bump workflow per branch.
RPM review and confirmation
hack/ubi-bump-prs.sh
Compares RPM inventories for the old and new image digests, reports file changes, and prompts whether to continue with pull request creation.
Commit, push, and PR creation
hack/ubi-bump-prs.sh
Creates digest-aware commits, pushes with optional force-with-lease recovery, opens pull requests, and prints created URLs or a no-PR summary.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Script
  participant Git
  participant Registry
  participant Podman
  participant GitHub
  Script->>Git: validate state and fetch upstream
  Script->>Registry: resolve latest UBI digest
  Script->>Git: create branch and run image bump
  Script->>Podman: compare RPM inventories
  Script->>Git: commit and push changes
  Script->>GitHub: create pull request
  GitHub-->>Script: return pull request URL
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers what and usage, but it omits the required Why and Tickets sections from the template. Add the missing Why and Tickets sections, and include the context/background plus any related Jira issue.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the new attended script for generating multi-branch UBI bump PRs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@qodo-for-conforma

Copy link
Copy Markdown

PR Summary by Qodo

Add attended script to open UBI bump PRs across release branches

✨ Enhancement 🕐 20-40 Minutes

Grey Divider

AI Description

• Add an attended helper to bump UBI base image digests across multiple branches.
• Include an RPM package diff in the commit message and PR body.
• Prompt before committing, pushing, and opening each branch-specific PR.
Diagram

graph TD
  dev(["Developer"]) --> script["hack/ubi-bump-prs.sh"] --> bump["hack/ubi-base-image-bump.sh"] --> rpmdiff["RPM diff (podman)"] --> prompt{"Confirm PR?"} --> pr["Create PR (gh)"]
  script --> upstream[("upstream remote")]
  script --> registry{{"UBI registry"}}
  pr --> origin[("origin remote")]
  subgraph Legend
    direction LR
    _u(["User"]) ~~~ _s["Script"] ~~~ _g[("Git remote")] ~~~ _e{{"External"}} ~~~ _d{"Decision"}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. GitHub Actions workflow (scheduled or manual dispatch)
  • ➕ Centralized, repeatable automation without requiring local podman/skopeo setup
  • ➕ Can enforce consistent PR formatting and ensure runs across all branches
  • ➖ More up-front CI plumbing and secrets/permissions management
  • ➖ Harder to keep “attended” semantics; may still need manual approval gates
2. Extend Renovate configuration to cover UBI digest + RPM context
  • ➕ Leverages an existing dependency bot workflow with less custom scripting
  • ➕ Can standardize across repos if Renovate is already widely used
  • ➖ Hard to include an RPM-level diff in PR body in a maintainable way
  • ➖ Renovate timing/triggering may not satisfy urgent bump needs

Recommendation: Keep this attended script as the pragmatic short-term solution for urgent, multi-branch UBI bumps (it composes well with the existing bump script and provides valuable RPM context). If bumps become routine and frequent, consider promoting the logic into a GitHub Actions workflow to reduce per-developer prerequisites and ensure consistent execution.

Files changed (1) +224 / -0

Other (1) +224 / -0
ubi-bump-prs.shAdd attended multi-branch UBI bump + PR creation script +224/-0

Add attended multi-branch UBI bump + PR creation script

• Introduces a new Bash script that loops through release branches, checks the latest ubi-minimal digest, runs the existing base-image bump script without committing, and computes an RPM package diff using podman. It then prompts for confirmation, commits with digest/RPM details, pushes the branch, and opens a PR via the GitHub CLI.

hack/ubi-bump-prs.sh

@simonbaird

Copy link
Copy Markdown
Member Author

@fullsend-ai-review

fullsend-ai-review Bot commented Jul 22, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 3:13 PM UTC · Completed 3:27 PM UTC
Commit: 87c4a29 · View workflow run →

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@hack/ubi-bump-prs.sh`:
- Around line 172-176: Update the failed-push handling around the git push in
the script to distinguish non-fast-forward failures, fetch the current remote
state before retrying, and use an explicit --force-with-lease instead of -f. Do
not offer or perform an unconditional force push; preserve the existing prompt
and branch variables while ensuring collaborators’ remote commits cannot be
silently overwritten.
- Around line 140-145: In the declined-PR branch of the interactive loop, reset
the work branch to "$UPSTREAM_REMOTE/$BRANCH" before continuing so the bump’s
tracked changes are discarded and later git checkout -B operations can proceed.
Update the logic surrounding the answer check and preserve the existing skip
messages and continue behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 49eab71c-fba6-403c-b62d-d77c46e186ef

📥 Commits

Reviewing files that changed from the base of the PR and between 8e9b358 and c48f604.

📒 Files selected for processing (1)
  • hack/ubi-bump-prs.sh

Comment thread hack/ubi-bump-prs.sh Outdated
Comment thread hack/ubi-bump-prs.sh Outdated
@qodo-for-conforma

qodo-for-conforma Bot commented Jul 22, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 27 rules

Grey Divider


Action required

1. Skip leaves dirty tree ✓ Resolved 🐞 Bug ☼ Reliability
Description
If the user declines PR creation after the bump runs, the script continues without resetting the
working tree, leaving modified files and likely breaking the next branch checkout (and preventing
EXIT cleanup from restoring the original branch). This can stop the multi-branch run mid-way and
leave the repo on a temporary branch with uncommitted changes.
Code

hack/ubi-bump-prs.sh[R105-146]

+	# Run the existing bump script (no commit)
+	hack/ubi-base-image-bump.sh --no-commit
+
+	# Verify the new digest (use whatever the bump script actually wrote)
+	NEW_DIGEST=$(grep -oP "ubi-minimal:latest@sha256:\K[0-9a-f]{64}" Dockerfile | head -1)
+	echo
+	echo "Digest after bump: sha256:${NEW_DIGEST:0:16}..."
+
+	# Generate RPM diff (amd64 — representative for commit/PR info)
+	echo
+	echo "Pulling images for RPM comparison..."
+	OLD_RPMS=$(podman run --rm "${UBI_MINIMAL_REPO}@sha256:$OLD_DIGEST" rpm -qa | sort)
+	NEW_RPMS=$(podman run --rm "${UBI_MINIMAL_REPO}@sha256:$NEW_DIGEST" rpm -qa | sort)
+
+	RPM_DIFF=$(diff \
+		--old-line-format='- %L' \
+		--new-line-format='+ %L' \
+		--unchanged-line-format='' \
+		<(echo "$OLD_RPMS") <(echo "$NEW_RPMS") || true)
+
+	echo
+	if [[ -n "$RPM_DIFF" ]]; then
+		echo "RPM changes:"
+		echo "$RPM_DIFF"
+	else
+		echo "No RPM changes detected."
+	fi
+
+	echo
+	echo "File changes:"
+	git diff --stat
+	echo
+
+	# --- Prompt ---------------------------------------------------------------
+
+	read -rp ">>> Create PR for $BRANCH? [y/N] " answer
+	echo
+	if [[ "${answer,,}" != "y" ]]; then
+		echo "Skipping $BRANCH."
+		echo
+		continue
+	fi
Relevance

⭐⭐ Medium

No historical evidence about resetting dirty trees on user skip; only general script cleanup
patterns seen.

PR-#3037

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new script runs the bump script before prompting and then continues on non-"y" without any
reset; the bump script demonstrably edits Dockerfiles via sed and runs hack/update-rpm-lock.sh,
so the working tree is left modified unless committed or reset.

hack/ubi-bump-prs.sh[65-67]
hack/ubi-bump-prs.sh[105-146]
hack/ubi-base-image-bump.sh[32-44]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`hack/ubi-bump-prs.sh` runs `hack/ubi-base-image-bump.sh --no-commit` before prompting. If the user answers anything other than `y`, the script `continue`s without cleaning up the modified working tree. That leaves tracked changes in place, which can cause subsequent `git checkout -B ...` to fail (changes would be overwritten) and also makes the EXIT `cleanup()` checkout unreliable (and it currently suppresses failures).

### Issue Context
The bump script edits Dockerfiles and updates `rpms.lock.yaml`, so after the bump step the tree is dirty unless you commit or reset.

### Fix Focus Areas
- hack/ubi-bump-prs.sh[65-67]
- hack/ubi-bump-prs.sh[105-146]

### Suggested fix
- Before each `continue` that skips PR creation (and also before exiting on push/PR-create failures), restore a clean state, e.g.:
 - `git reset --hard` (or `git reset --hard "$UPSTREAM_REMOTE/$BRANCH"`)
 - `git clean -fd` (in case the bump script ever creates files)
- Consider enhancing `cleanup()` to also hard-reset/clean if currently on a work branch, so it can reliably return to `ORIGINAL_BRANCH` even after partial runs.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. RPM diff arch not pinned ✓ Resolved 🐞 Bug ≡ Correctness
Description
The script claims the RPM diff is "amd64", but the podman run commands do not specify
--platform, so on non-amd64 hosts the RPM list can differ (or fail) and the commit/PR metadata
becomes inaccurate. This repo already pins linux/amd64 for RPM lock generation to avoid
platform-variant issues.
Code

hack/ubi-bump-prs.sh[R113-118]

+	# Generate RPM diff (amd64 — representative for commit/PR info)
+	echo
+	echo "Pulling images for RPM comparison..."
+	OLD_RPMS=$(podman run --rm "${UBI_MINIMAL_REPO}@sha256:$OLD_DIGEST" rpm -qa | sort)
+	NEW_RPMS=$(podman run --rm "${UBI_MINIMAL_REPO}@sha256:$NEW_DIGEST" rpm -qa | sort)
+
Relevance

⭐⭐⭐ High

PR #3037 added linux/amd64 pin on podman run/build for consistent results; likely to want same here.

PR-#3037

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new script runs podman run without --platform even though it states amd64 intent; a related
repo script explicitly pins linux/amd64, indicating this is important for consistent results.

hack/ubi-bump-prs.sh[113-118]
hack/update-rpm-lock.sh[26-29]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The RPM comparison uses `podman run` without `--platform`, so the RPM lists are host-architecture dependent. The script comment says "amd64" but the implementation does not enforce it.

### Issue Context
`hack/update-rpm-lock.sh` explicitly pins `PLATFORM="linux/amd64"` for compatibility with base images, suggesting cross-arch differences are already a known concern in this repo.

### Fix Focus Areas
- hack/ubi-bump-prs.sh[113-118]

### Suggested fix
- Add a `PLATFORM=linux/amd64` variable (optionally overridable via env) and use it for both runs:
 - `podman run --platform "$PLATFORM" --rm ... rpm -qa`
- Update the comment to match the enforced behavior (or remove "amd64" wording if you intend host-arch diffs).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Bash 4-only lowercase ✓ Resolved 🐞 Bug ☼ Reliability
Description
The script uses ${answer,,} / ${force_answer,,} for case-folding, which requires Bash 4+ and
will fail on older Bash installations. This makes the script unexpectedly non-portable for developer
environments.
Code

hack/ubi-bump-prs.sh[R140-176]

+	read -rp ">>> Create PR for $BRANCH? [y/N] " answer
+	echo
+	if [[ "${answer,,}" != "y" ]]; then
+		echo "Skipping $BRANCH."
+		echo
+		continue
+	fi
+
+	# --- Commit ---------------------------------------------------------------
+
+	COMMIT_MSG="chore(deps): Update ubi-minimal base image
+
+Old digest: sha256:$OLD_DIGEST
+New digest: sha256:$NEW_DIGEST"
+
+	if [[ -n "$RPM_DIFF" ]]; then
+		COMMIT_MSG="$COMMIT_MSG
+
+RPM changes:
+
+$RPM_DIFF"
+	fi
+
+	EXISTING_FILES=()
+	for f in "${DOCKER_FILES[@]}" rpms.lock.yaml; do
+		[[ -f "$f" ]] && EXISTING_FILES+=("$f")
+	done
+	git add "${EXISTING_FILES[@]}"
+	git commit -m "$COMMIT_MSG"
+
+	# --- Push -----------------------------------------------------------------
+
+	if ! git push -u "$PUSH_REMOTE" "$WORK_BRANCH" 2>&1; then
+		echo
+		read -rp ">>> Push failed (branch may already exist). Force push? [y/N] " force_answer
+		if [[ "${force_answer,,}" == "y" ]]; then
+			git push -f -u "$PUSH_REMOTE" "$WORK_BRANCH"
Relevance

⭐⭐ Medium

No historical reviews found about avoiding Bash 4-only ${var,,}; portability intent unclear despite
macOS tooling.

PR-#2977
PR-#3037

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new script uses ${var,,} for prompt handling in two places, which is a Bash 4+ feature and
thus can cause runtime failure in environments with older Bash.

hack/ubi-bump-prs.sh[140-146]
hack/ubi-bump-prs.sh[172-177]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The script uses Bash 4+ case conversion `${var,,}` when checking prompt responses, which breaks on older Bash versions.

### Issue Context
This script is intended as an attended developer tool, so it should either (a) run on common developer shells or (b) explicitly assert a minimum Bash version.

### Fix Focus Areas
- hack/ubi-bump-prs.sh[140-146]
- hack/ubi-bump-prs.sh[174-177]

### Suggested fix
- Replace `${answer,,}` checks with a Bash-3-compatible construct, e.g.:
 - `case "$answer" in [yY]) ... ;; *) ... ;; esac`
- Alternatively, add an early version guard (`BASH_VERSINFO`) with a clear error message if Bash < 4 is detected.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Non-portable grep -P ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
Digest parsing relies on grep -oP with PCRE-specific \K, which is not universally available
(e.g., BSD grep) and can make the script fail in otherwise valid environments. The repo’s existing
bump script avoids this by using sed -E for digest handling.
Code

hack/ubi-bump-prs.sh[R87-89]

+	OLD_DIGEST=$(git show "$UPSTREAM_REMOTE/$BRANCH:Dockerfile" \
+		| grep -oP "ubi-minimal:latest@sha256:\K[0-9a-f]{64}" | head -1)
+
Relevance

⭐⭐ Medium

Repo values macOS portability (explicit platform pin), but no prior grep -P/-oP portability
enforcement evidence.

PR-#3037

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new script uses grep -oP for digest extraction; the existing bump script uses sed -E
patterns for digest handling, demonstrating a more portable approach already in-repo.

hack/ubi-bump-prs.sh[87-89]
hack/ubi-bump-prs.sh[108-110]
hack/ubi-base-image-bump.sh[33-37]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`hack/ubi-bump-prs.sh` uses `grep -oP ... \K...` to extract digests. This depends on GNU grep PCRE support and is a common portability failure.

### Issue Context
`hack/ubi-base-image-bump.sh` already uses `sed -E` for digest replacement, which is typically more portable.

### Fix Focus Areas
- hack/ubi-bump-prs.sh[87-89]
- hack/ubi-bump-prs.sh[108-110]

### Suggested fix
- Replace the `grep -oP` extraction with a `sed -nE` capture, e.g.:
 - `sed -nE 's/.*ubi-minimal:latest@sha256:([0-9a-f]{64}).*/\1/p' | head -1`
- Add a clear error if extraction returns empty (so failures are actionable).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread hack/ubi-bump-prs.sh Outdated
Comment thread hack/ubi-bump-prs.sh Outdated
Comment thread hack/ubi-bump-prs.sh Outdated
Comment thread hack/ubi-bump-prs.sh Outdated
Comment on lines +140 to +176
read -rp ">>> Create PR for $BRANCH? [y/N] " answer
echo
if [[ "${answer,,}" != "y" ]]; then
echo "Skipping $BRANCH."
echo
continue
fi

# --- Commit ---------------------------------------------------------------

COMMIT_MSG="chore(deps): Update ubi-minimal base image

Old digest: sha256:$OLD_DIGEST
New digest: sha256:$NEW_DIGEST"

if [[ -n "$RPM_DIFF" ]]; then
COMMIT_MSG="$COMMIT_MSG

RPM changes:

$RPM_DIFF"
fi

EXISTING_FILES=()
for f in "${DOCKER_FILES[@]}" rpms.lock.yaml; do
[[ -f "$f" ]] && EXISTING_FILES+=("$f")
done
git add "${EXISTING_FILES[@]}"
git commit -m "$COMMIT_MSG"

# --- Push -----------------------------------------------------------------

if ! git push -u "$PUSH_REMOTE" "$WORK_BRANCH" 2>&1; then
echo
read -rp ">>> Push failed (branch may already exist). Force push? [y/N] " force_answer
if [[ "${force_answer,,}" == "y" ]]; then
git push -f -u "$PUSH_REMOTE" "$WORK_BRANCH"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

4. Bash 4-only lowercase 🐞 Bug ☼ Reliability

The script uses ${answer,,} / ${force_answer,,} for case-folding, which requires Bash 4+ and
will fail on older Bash installations. This makes the script unexpectedly non-portable for developer
environments.
Agent Prompt
### Issue description
The script uses Bash 4+ case conversion `${var,,}` when checking prompt responses, which breaks on older Bash versions.

### Issue Context
This script is intended as an attended developer tool, so it should either (a) run on common developer shells or (b) explicitly assert a minimum Bash version.

### Fix Focus Areas
- hack/ubi-bump-prs.sh[140-146]
- hack/ubi-bump-prs.sh[174-177]

### Suggested fix
- Replace `${answer,,}` checks with a Bash-3-compatible construct, e.g.:
  - `case "$answer" in [yY]) ... ;; *) ... ;; esac`
- Alternatively, add an early version guard (`BASH_VERSINFO`) with a clear error message if Bash < 4 is detected.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed.

@fullsend-ai-review

fullsend-ai-review Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review

Findings

Medium

  • [edge-case] hack/ubi-bump-prs.sh:106 — When NEW_DIGEST extraction fails after the bump script has already modified files (line 100: hack/ubi-base-image-bump.sh --no-commit), the continue on line 106 skips to the next branch iteration without cleaning up the dirty working tree. The next iteration’s git checkout -B will fail because git refuses to overwrite uncommitted modifications. With set -o errexit, this kills the script, and the cleanup trap’s git checkout may also fail for the same reason, leaving the repository in a dirty state on the wrong branch.
    Remediation: Add git reset --hard "$UPSTREAM_REMOTE/$BRANCH" before the continue on line 106, matching the reset done on the user-skip path (line 137).

  • [indentation] hack/ubi-bump-prs.sh:37 — The script uses hard tab indentation throughout, while all other hack/ shell scripts consistently use 2-space indentation (verified against ubi-base-image-bump.sh, cut-release.sh, go-mod-upgrade-helper.sh, derive-version.sh, add-auto-tag.sh, bump-tekton-bundles.sh, and update-rpm-lock.sh).
    Remediation: Convert tab indentation to 2-space indentation: expand -t 2 hack/ubi-bump-prs.sh > tmp && mv tmp hack/ubi-bump-prs.sh

Low

  • [edge-case] hack/ubi-bump-prs.sh:73LATEST_DIGEST is computed once at setup via skopeo inspect --raw | sha256sum, but the inner hack/ubi-base-image-bump.sh runs its own independent skopeo inspect. If the :latest tag moves between calls, the initial printout may differ from the actual digest written. Cosmetic only — commit messages and PR bodies correctly use NEW_DIGEST extracted from the Dockerfile after the bump.

  • [maintenance] hack/ubi-bump-prs.sh:48 — The DOCKER_FILES array duplicates the identical array in hack/ubi-base-image-bump.sh (line 33). If the inner script’s list changes, the outer script’s git add (lines 149–152) would miss newly-modified Dockerfiles, resulting in partial commits. Consider using git add -u to add all modified tracked files, or sourcing the list from a shared location.

  • [command-injection] hack/ubi-bump-prs.sh:37 — Branch names from command-line arguments flow into git show, git checkout -B, git push, and gh pr create --base commands. Mitigated by proper quoting of $BRANCH in all uses and git’s own naming constraints; further reduced by the attended, interactive nature of the script.

  • [command-injection] hack/ubi-bump-prs.sh:113 — Containers run via podman run --rm without explicit security hardening flags (--security-opt, --cap-drop, etc.). Digest values are regex-constrained to [0-9a-f]{64}, preventing injection through the digest string. Matches the existing hack/update-rpm-lock.sh pattern.

Previous run

Review

Findings

Medium

  • [error handling] hack/ubi-bump-prs.sh:87 — The pipeline git show "$UPSTREAM_REMOTE/$BRANCH:Dockerfile" | grep -oP ... | head -1 will exit non-zero (and terminate the entire script due to set -o errexit + set -o pipefail) if the branch does not exist, the Dockerfile is missing on that branch, or the Dockerfile does not contain the expected ubi-minimal:latest@sha256: pattern. Since the script accepts arbitrary branch names as arguments, a typo or a branch that has diverged in Dockerfile format kills the whole script and aborts processing of any remaining branches.
    Remediation: Wrap the OLD_DIGEST extraction in a guard that catches failures and skips the branch, e.g.:
    if ! OLD_DIGEST=$(git show "$UPSTREAM_REMOTE/$BRANCH:Dockerfile" \
        | grep -oP "ubi-minimal:latest@sha256:\K[0-9a-f]{64}" | head -1) || [[ -z "$OLD_DIGEST" ]]; then
        echo "Could not extract current digest for $BRANCH, skipping."
        echo
        continue
    fi

Low

  • [edge case] hack/ubi-bump-prs.sh:100 — The NEW_DIGEST extraction (grep -oP ... Dockerfile | head -1) reads from the local Dockerfile after hack/ubi-base-image-bump.sh --no-commit runs. If the inner script succeeds but the Dockerfile format has changed such that the grep pattern doesn't match, grep returns exit 1 and the script terminates without a clear message. Practically unlikely since both scripts use the same pattern, but the coupling is implicit.

  • [race condition] hack/ubi-bump-prs.sh:73LATEST_DIGEST is computed once at setup via skopeo inspect, then hack/ubi-base-image-bump.sh independently calls skopeo inspect again for each branch. If the upstream image is republished between calls, the staleness check at line 91 may skip a branch that could have been bumped. Unlikely in practice given UBI image update frequency, and the attended nature of the script means the operator would catch it on the next run.


Labels: PR adds developer automation tooling in hack/ for UBI base image management

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added requires-manual-review Review requires human judgment tooling labels Jul 22, 2026
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
acceptance 54.25% <ø> (-0.01%) ⬇️
generative 16.80% <ø> (ø)
integration 27.97% <ø> (ø)
unit 71.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Wraps hack/ubi-base-image-bump.sh to automate creating PRs for all
active branches, including an RPM version diff in the commit and PR
body.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simonbaird
simonbaird force-pushed the ubi-bump-automation branch from c48f604 to a3090fb Compare July 23, 2026 13:26
@github-actions github-actions Bot added size: XL and removed size: L labels Jul 23, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 1:27 PM UTC · Completed 1:44 PM UTC
Commit: 87c4a29 · View workflow run →

@simonbaird
simonbaird enabled auto-merge July 23, 2026 13:29

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

See the review comment for full details.

Comment thread hack/ubi-bump-prs.sh

# Checkout working branch
WORK_BRANCH="ubi-bump-${BRANCH}"
git checkout -B "$WORK_BRANCH" "$UPSTREAM_REMOTE/$BRANCH" --no-track

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[medium] edge-case

When NEW_DIGEST extraction fails after the bump script has already modified files (line 100: hack/ubi-base-image-bump.sh --no-commit), the continue on line 106 skips to the next branch iteration without cleaning up the dirty working tree. The next iteration's git checkout -B will fail because git refuses to overwrite uncommitted modifications. With set -o errexit, this kills the script, and the cleanup trap's git checkout may also fail, leaving the repository in a dirty state on the wrong branch.

Suggested fix: Add git reset --hard "$UPSTREAM_REMOTE/$BRANCH" before the continue on line 106, matching the reset done on the user-skip path (line 137).

Comment thread hack/ubi-bump-prs.sh

if [[ $# -gt 0 ]]; then
BRANCHES=("$@")
else

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[medium] indentation

The script uses hard tab indentation throughout, while all other hack/ shell scripts consistently use 2-space indentation. Verified against ubi-base-image-bump.sh, cut-release.sh, go-mod-upgrade-helper.sh, derive-version.sh, add-auto-tag.sh, bump-tekton-bundles.sh, and update-rpm-lock.sh.

Suggested fix: Convert tab indentation to 2-space indentation to match the established convention.

Comment thread hack/ubi-bump-prs.sh
git fetch "$UPSTREAM_REMOTE"
echo

echo "=== Checking latest $UBI_MINIMAL digest ==="

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] edge-case

LATEST_DIGEST is computed once at setup via skopeo inspect --raw | sha256sum, but the inner hack/ubi-base-image-bump.sh runs its own independent skopeo inspect. If the :latest tag moves between calls, the initial printout may differ from the actual digest written. Cosmetic only — commit messages and PR bodies correctly use NEW_DIGEST from the Dockerfile.

Comment thread hack/ubi-bump-prs.sh
UBI_MINIMAL="${UBI_MINIMAL_REPO}:latest"

DOCKER_FILES=(Dockerfile Dockerfile.dist acceptance/kubernetes/kind/acceptance.Dockerfile)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] maintenance

The DOCKER_FILES array duplicates the identical array in hack/ubi-base-image-bump.sh (line 33). If the inner script's list changes, the outer script's git add would miss newly-modified Dockerfiles, resulting in partial commits.

Suggested fix: Consider using git add -u to add all modified tracked files, or sourcing the list from a shared location.

Comment thread hack/ubi-bump-prs.sh

if [[ $# -gt 0 ]]; then
BRANCHES=("$@")
else

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] command-injection

Branch names from command-line arguments flow into git show, git checkout -B, git push, and gh pr create --base commands. Mitigated by proper quoting of $BRANCH in all uses and git's naming constraints; further reduced by the attended, interactive nature of the script.

Comment thread hack/ubi-bump-prs.sh
hack/ubi-base-image-bump.sh --no-commit

# Verify the new digest (use whatever the bump script actually wrote)
NEW_DIGEST=$(sed -nE 's/.*ubi-minimal:latest@sha256:([0-9a-f]{64}).*/\1/p' Dockerfile | head -1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] command-injection

Containers run via podman run --rm without explicit security hardening flags. Digest values are regex-constrained to [0-9a-f]{64}, preventing injection. Matches the existing hack/update-rpm-lock.sh pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires-manual-review Review requires human judgment size: XL tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant