In this lesson, you’ll extend your GitHub Actions CI workflow to publish a Docker image to Docker Hub. We’ll build the image for testing, verify it runs correctly, and then push it to your Docker Hub registry—all within a single workflow file.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Ensure you’ve configured the following GitHub repository secrets:
DOCKERHUB_USERNAMEDOCKERHUB_TOKENMONGO_URI,MONGO_USERNAME,MONGO_PASSWORD
Updated Workflow Snippet
Add these three steps to your.github/workflows/ci.yml:
Step-by-Step Breakdown
| Step Name | Action | Description |
|---|---|---|
| Docker Build for Testing | docker/build-push-action@v4 | Builds the image locally without pushing to the registry |
| Docker Image Testing | run | Starts a container, retrieves its IP, and tests the /live endpoint |
| Docker Push | docker/build-push-action@v4 | Re-builds (using cache) and uploads all layers to Docker Hub |
Inspecting the Push Logs
During the Docker Push step you’ll see output similar to:Verify the Image on Docker Hub
Once the workflow completes:- Go to your repository on Docker Hub.
- Look under Tags for the SHA-based tag (e.g.,
e8095fb98a5b01249548095eaf3a9c371c274430).
If you see authentication errors, double-check that
DOCKERHUB_TOKEN is up to date and has the correct permissions.