Build and Push the Image on Release
Automate container builds when you tag a release.
Build and Push the Image on Release is a free MLOps Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MLOps Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Build Only on Release
You do not ship an image on every commit. The release step builds and publishes a container only when you mark a version as ready. 📦
Trigger on a Tag
A common pattern fires the build when you push a git tag like v1.2.0, so a deliberate version, not a casual push, starts the deploy.
on:
push:
tags: ["v*"]What a Build Produces
The build packs your model API, its code, and dependencies into one image: a frozen, runnable snapshot that behaves the same on any machine.
A Registry Stores Images
A container registry like GHCR, ECR, or Docker Hub is where built images live so any server can later pull and run them.
Log In With a Secret
Before pushing, the workflow logs into the registry using a stored secret, never a hardcoded password, keeping credentials out of your code.
- uses: docker/login-action@v3
with:
password: ${{ secrets.REGISTRY_TOKEN }}Tag the Image Well
Give the image a clear tag that matches your release version. Reusing latest alone makes it impossible to tell which build is running.
myorg/model-api:v1.2.0Build and Push in One Action
The official Docker build-push action builds your Dockerfile and uploads the result to the registry in a single step.
- uses: docker/build-push-action@v6
with:
push: true
tags: myorg/model-api:v1.2.0Pin the Version, Not latest
Deploying a pinned tag like v1.2.0 means you always know exactly which model and code are live, and you can roll back to an earlier tag fast.
Cache Layers for Speed
Image builds reuse unchanged layers from a cache, so only the parts you actually changed rebuild. This keeps release builds quick.
Deploy Pulls the Image
Once pushed, your runtime simply pulls the tagged image and starts it. The same artifact you tested is the one that goes live, byte for byte.
docker pull myorg/model-api:v1.2.0Release Notes Close the Loop
Tie the image tag to a GitHub release with notes on what changed. Now anyone can trace a running container back to its exact code and model.
Quick Check
Why tag the released image with a version instead of only latest?
Recap
On a version tag, log in with a secret, build the image, and push it to a registry under a pinned tag. Your runtime pulls that exact artifact to go live.
Frequently asked questions
Is the “Build and Push the Image on Release” lesson free?
Yes — the full text of “Build and Push the Image on Release” is free to read here on the web, and the MLOps Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MLOps Academy course, upgrade to CoddyKit PRO.
What will I learn in “Build and Push the Image on Release”?
Automate container builds when you tag a release. You practise MLOps Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MLOps Academy?
No prior experience is required. MLOps Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Build and Push the Image on Release” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MLOps Academy lesson?
Yes. Every MLOps Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What CI/CD Means for Models
- A GitHub Actions Workflow for ML
- Gate Merges on Model Quality
- Build and Push the Image on Release