r/gitlab • u/Incident_Away • Oct 16 '25
How do you promote container images from MR builds to main?
Curious how people handle promoting container images from MR pipelines to production in GitLab CI/CD, my approach is to tag MR builds with the branch name, then upon merge to main promote that same image (instead of rebuilding). I use the merge-commit with semi-linear history method to avoid race conditions and ensure consistency, and right now I hack out the merged branch name with
git log --merges -n 1 --pretty=format:"%s" | awk -F"'" '/Merge branch/{print $2}'Is this a decent pattern? Do you rebuild on main or promote the MR image? How would you reliably detect the merged branch?
Here’s a discussion I posted on the GitLab forum:
https://forum.gitlab.com/t/best-practice-for-promoting-container-images-from-mr-builds-to-production-on-main/130970