Skip to content

ci: branch-tagged image builds via workflow_dispatch (insight#1994 Phase 1) - #227

Merged
cyberantonz merged 1 commit into
constructorfabric:mainfrom
cyberantonz:feat/branch-image-builds-1994
Jul 29, 2026
Merged

ci: branch-tagged image builds via workflow_dispatch (insight#1994 Phase 1)#227
cyberantonz merged 1 commit into
constructorfabric:mainfrom
cyberantonz:feat/branch-image-builds-1994

Conversation

@cyberantonz

@cyberantonz cyberantonz commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Companion to constructorfabric/insight#2004 — Phase 1 of constructorfabric/insight#1994 (manual branch builds + image report).

What changes

  • Branch-aware build tag: a workflow_dispatch from a non-main ref now produces ghcr.io/constructorfabric/insight-front:<YYYY.MM.DD.HH.MM>-<sha7>.<sanitized-branch> (same sanitization as the insight side: docker-tag charset, edge separators trimmed, 60-char cap). Main keeps the suffix-less format.
  • The build tag is applied on every run: the only triggers are main pushes and workflow_dispatch, and a branch dispatch is a deliberate branch image build — previously it pushed only untagged digests (wasted work).
  • latest stays default-branch-only (enable={{is_default_branch}}, unchanged).
  • Step-summary report: the merge job writes the pushed ref to $GITHUB_STEP_SUMMARY.

What deliberately does not change

  • dispatch-umbrella keeps its ref == main gate — a branch build never pins the frontend subchart appVersion in the umbrella chart.
  • Main-push behavior is identical to today.

Usage

gh workflow run docker.yml --repo constructorfabric/insight-front --ref my-branch

or Actions → Docker ImageRun workflow → pick the branch (must live in this repo, not a fork).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added branch-specific Docker image tags for builds from non-default branches.
    • Added the pushed image reference to the workflow run summary.
  • Bug Fixes

    • Ensured build tags are applied consistently across all workflow runs.
    • Preserved the latest tag for default-branch builds only.

…ase 1)

A workflow_dispatch from any branch now pushes the frontend image tagged
<date>-<sha7>.<sanitized-branch> (branch name sanitized to the docker-tag
charset, capped at 60 chars). Main keeps the suffix-less tag format.
Previously a branch dispatch pushed only untagged digests — wasted work.

`latest` stays default-branch-only and dispatch-umbrella keeps its
main-only gate, so a branch build never moves `latest` nor pins the
umbrella subchart appVersion. The merge job now also writes the pushed
ref to the run's step summary for copy-paste.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Anton Zelenov <antonz@constructor.tech>
@cyberantonz
cyberantonz requested a review from a team as a code owner July 29, 2026 03:20
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Docker workflow now creates branch-specific build tags, applies those tags to images from all runs, preserves default-branch-only latest tagging, and reports the pushed image reference in the workflow summary.

Changes

Docker image publishing

Layer / File(s) Summary
Branch-aware build tag computation
.github/workflows/docker.yml
Non-main branch names are sanitized and appended to the existing date and short-SHA build tag.
Image tagging and publication reporting
.github/workflows/docker.yml
The computed build tag is applied on every run, while latest remains restricted to the default branch; the pushed image reference is added to the workflow summary.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Possibly related issues

  • constructorfabric/insight#1994 — Covers branch-tagged GHCR images and reporting the resulting image reference.

Suggested reviewers: aleksdotbar, artifizer, blackcelebrant

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: branch-tagged image builds triggered by workflow_dispatch.
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

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.

❤️ Share

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

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

🧹 Nitpick comments (2)
.github/workflows/docker.yml (2)

159-168: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Update the stale workflow comments about branch pushes.

Non-main workflow_dispatch runs now publish a branch-suffixed build_tag, but later comments still say those runs push no image and describe every build as producing build_tag plus latest. Clarify that branch runs publish only their computed tag, while latest remains default-branch-only.

🤖 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/docker.yml around lines 159 - 168, The comments
surrounding the Docker image tag configuration are stale. Update the later
workflow comments to state that non-main workflow_dispatch runs publish only
their computed branch-suffixed build_tag, while default-branch runs may also
publish latest; remove claims that branch runs publish no image or that every
build produces both tags.

177-180: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Pass the image reference through env instead of interpolating it into shell source.

The current sanitizer makes this value safe today, but direct template expansion in run is the injection pattern reported by zizmor. Use an environment variable so the shell never parses the computed output as code.

Proposed fix
       - name: Report pushed image
+        env:
+          IMAGE_REF: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.build_tag }}
         run: |
-          echo '- `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.build_tag }}`' >> "$GITHUB_STEP_SUMMARY"
+          printf '%s\n' "- \`${IMAGE_REF}\`" >> "$GITHUB_STEP_SUMMARY"
🤖 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/docker.yml around lines 177 - 180, Update the “Report
pushed image” workflow step to pass the computed image reference through the
step’s env configuration, then have the run script append that environment
variable to GITHUB_STEP_SUMMARY. Remove direct GitHub expression interpolation
of the image value from shell source while preserving the existing summary
format.

Source: Linters/SAST tools

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

Nitpick comments:
In @.github/workflows/docker.yml:
- Around line 159-168: The comments surrounding the Docker image tag
configuration are stale. Update the later workflow comments to state that
non-main workflow_dispatch runs publish only their computed branch-suffixed
build_tag, while default-branch runs may also publish latest; remove claims that
branch runs publish no image or that every build produces both tags.
- Around line 177-180: Update the “Report pushed image” workflow step to pass
the computed image reference through the step’s env configuration, then have the
run script append that environment variable to GITHUB_STEP_SUMMARY. Remove
direct GitHub expression interpolation of the image value from shell source
while preserving the existing summary format.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e9594429-aeef-4d53-963c-9e8b36d431f3

📥 Commits

Reviewing files that changed from the base of the PR and between f6bd345 and e1a6ba6.

📒 Files selected for processing (1)
  • .github/workflows/docker.yml

@cyberantonz
cyberantonz merged commit 46dff4a into constructorfabric:main Jul 29, 2026
6 checks passed
@cyberantonz
cyberantonz deleted the feat/branch-image-builds-1994 branch July 29, 2026 03:48
ktursunov pushed a commit that referenced this pull request Jul 29, 2026
docker.yml conflicted: #227 (branch-tagged image builds) added a
"Report pushed image" step at the end of the merge job, exactly where this
branch appends the trivy-image job. Both kept — the step stays inside merge,
trivy-image follows as a separate job.

trivy-image's gating comment was stale after #227: it justified the main-only
condition by metadata-action's enable={{is_default_branch}}, which #227 removed
so branch dispatches now push a tagged image too. The condition is unchanged
(main-only, matching the promotion path it guards); the comment now says why and
how to widen it. needs.merge.outputs.build_tag still resolves — merge forwards
prepare's branch-suffixed tag.

Signed-off-by: Konstantin Tursunov <konstantin.tursunov@constructor.tech>
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