Skip to content

ci: only publish the Docker image from master - #12

Merged
widgetii merged 2 commits into
masterfrom
scope-docker-publish-to-master
Sep 24, 2026
Merged

widgetii merged 2 commits into
masterfrom
scope-docker-publish-to-master

Conversation

@widgetii

Copy link
Copy Markdown
Member

main.yml triggered on push to every branch:

on:
  push:
    branches:
      - "*"

Since it builds and pushes braunbearded/python-dvr:latest unconditionally, any push to any branch rebuilt and overwrote :latest on Docker Hub with that branch's code — a footgun.

This scopes the trigger to master, so :latest tracks master only. workflow_dispatch is kept for manual runs, and the per-commit :${{ github.sha }} tag is unchanged.

No functional change to the image itself.

main.yml triggered on push to every branch (branches: "*"), so any
branch push rebuilt and overwrote braunbearded/python-dvr:latest on
Docker Hub. Scope the trigger to master so :latest tracks master only;
workflow_dispatch stays for manual runs.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Restrict automatic Docker image publishing to master

🐞 Bug fix ⚙️ Configuration changes 🕐 Less than 5 minutes

Grey Divider

AI Description

• Publishes Docker images automatically only for pushes to master.
• Prevents feature branches from overwriting Docker Hub’s latest tag.
• Retains manual dispatch and commit-specific image tags.
High-Level Assessment

The branch-scoped push trigger is the simplest and most appropriate fix. Adding conditional publish logic at the job or step level would preserve unnecessary workflow executions and increase configuration complexity.

Files changed (1) +1 / -1

Bug fix (1) +1 / -1
main.ymlLimit automatic Docker publishing to master +1/-1

Limit automatic Docker publishing to master

• Changes the push trigger from every branch to 'master', preventing branch builds from automatically replacing the 'latest' Docker image. Manual workflow dispatch and SHA-specific tagging remain unchanged.

.github/workflows/main.yml

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Manual runs can overwrite the master image ✓ Resolved 🐞 Bug ≡ Correctness
Description
The workflow_dispatch trigger remains unrestricted while the Docker step always pushes the selected
revision to the latest tag. A maintainer who manually runs the workflow from a feature branch can
therefore overwrite the Docker Hub image with non-master code despite the new push filter.
Code

.github/workflows/main.yml[5]

+      - master
Evidence
The added branch filter applies only to push events; workflow_dispatch remains a separate
unrestricted trigger. The Docker build-and-push action unconditionally sets push: true and
publishes latest, so a manually selected non-master ref can still replace the image.

.github/workflows/main.yml[2-6]
.github/workflows/main.yml[16-24]

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

## Issue description
Manual workflow dispatches can be started from a feature branch, and the unconditional Docker push then overwrites the `latest` tag with that branch's code.
## Fix Focus Areas
- .github/workflows/main.yml[2-24]
## Recommended Fix
Keep `workflow_dispatch` if needed, but add a job or step condition that permits Docker publishing only when `github.ref` is `refs/heads/master` (or otherwise make manual runs from non-master refs build without pushing). Ensure both `latest` and commit-specific tags follow the intended publishing policy.

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


Grey Divider

Tip of the day
💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread .github/workflows/main.yml
Address review: the push branch filter alone did not cover
workflow_dispatch, so a manual run selecting a feature branch would
still publish and overwrite :latest. Gate the docker job on
github.ref == refs/heads/master so only master publishes, regardless of
how the workflow is triggered.
@widgetii
widgetii merged commit 51e6961 into master Sep 24, 2026
6 checks passed
@widgetii
widgetii deleted the scope-docker-publish-to-master branch September 24, 2026 13:06
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