Skip to content

Only push to GHCR on merge to main - #122

Merged
gekiclaws merged 2 commits into
mainfrom
chore/ci-deploy-main-only
Apr 27, 2026
Merged

gekiclaws merged 2 commits into
mainfrom
chore/ci-deploy-main-only

Conversation

@thejonathangu

Copy link
Copy Markdown
Collaborator

Summary

The deploy job in ci-cd.yml currently runs on every same-repo pull request and pushes images to GHCR tagged pr-<num> and pr-<num>-sha-<sha>. That clutters the registry with throwaway tags and exposes packages: write on every PR-triggered run.

This PR restricts deploy to push events on main only. Pull requests still run the full detect-changes + build + backend-integration matrix; they just no longer publish images.

Changes

  • deploy.if drops the pull_request branch — now gated on github.event_name == 'push' && github.ref == 'refs/heads/main'.
  • "Compute image tags" step simplified: no pr-<num> branch, only emits :latest and :sha-<sha>.
  • Comment added on the deploy job explaining the policy.

Net diff: +12 / -23 lines, single file (.github/workflows/ci-cd.yml).

Test plan

  • CI on this PR runs detect-changes → build → backend-integration and does not run build & push GHCR images.
  • No new tags appear under ghcr.io/cmu-413/avenu-* while this PR is open.
  • After merge, the push-to-main run executes deploy and publishes :latest + :sha-<sha> for each changed service.
  • An existing image consumer (e.g. prod compose pulling :latest) still resolves after the next merge.

The deploy job previously ran on every same-repo pull request, pushing
`pr-NN` and `pr-NN-sha-...` images to GHCR. That cluttered the registry
and exposed `packages: write` on PR-triggered runs.

Restrict the deploy job to `push` events on `main`. Pull requests still
exercise the build, test, and integration jobs but no longer publish
images. Simplifies the tag-computation step accordingly (no PR branch
left to handle).

Made-with: Cursor
@gekiclaws gekiclaws changed the title ci: only push to GHCR on merge to main Only push to GHCR on merge to main Apr 27, 2026
@gekiclaws gekiclaws self-assigned this Apr 27, 2026
@gekiclaws gekiclaws added the enhancement New feature or request label Apr 27, 2026
@gekiclaws gekiclaws added this to the v1.0 milestone Apr 27, 2026
@gekiclaws
gekiclaws self-requested a review April 27, 2026 21:05
@gekiclaws
gekiclaws merged commit 5c563b8 into main Apr 27, 2026
4 checks passed
@gekiclaws
gekiclaws deleted the chore/ci-deploy-main-only branch April 27, 2026 21:05
@gekiclaws

Copy link
Copy Markdown
Contributor

Forgot to click approve. But looks good!

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants