This repository contains a GitHub Actions workflow only for one micro service that is Product Catalog that builds, tests, performs code-quality checks, builds Docker images, and updates Kubernetes manifests for the Product Catalog microservice.
The workflow runs automatically on pull requests to the main branch.
It includes four jobs:
-
Build & Unit Tests
- Sets up Go 1.22
- Builds the Product Catalog Service (
main.go) - Runs unit tests
-
Code Quality
- Uses
golangci-lintto enforce coding standards and detect issues
- Uses
-
Docker Build & Push
- Builds a Docker image for the Product Catalog service
- Pushes it to Docker Hub with a unique
run_idtag
-
Kubernetes Manifest Update
- Updates the image tag in the Kubernetes
deploy.yamlfile - Commits and pushes the updated manifest back to the
mainbranch
- Updates the image tag in the Kubernetes
You need to add the following secrets in your GitHub repository:
| Secret Name | Description |
|---|---|
DOCKER_USERNAME |
Your Docker Hub username |
DOCKER_TOKEN |
Docker Hub Access Token (not password) |
GITHUB_TOKEN |
Provided by GitHub automatically (no setup needed) |
➡️ Go to: Repo Settings > Secrets and Variables > Actions > New Repository Secret
src/product-catalog/ # Source code for Product Catalog service
├── main.go
├── go.mod
├── Dockerfile
kubernetes/productcatalog/ # Kubernetes deployment manifests
├── deploy.yaml
.github/workflows/ # CI/CD workflows
├── product-catalog-ci.yml
- Developer raises a Pull Request to
main - GitHub Actions workflow triggers
- Workflow performs:
- ✅ Build & Unit Tests
- ✅ Code Quality Check
- ✅ Docker Build & Push →
dockerhub_username/product-catalog:<run_id> - ✅ Update Kubernetes manifest → auto-commits new image tag
Each image pushed to Docker Hub is tagged with the GitHub Run ID, ensuring a unique version for every pipeline run:
dockerhub_username/product-catalog:1234567890
The workflow automatically updates:
# kubernetes/productcatalog/deploy.yaml
image: dockerhub_username/product-catalog:<run_id>so your Kubernetes cluster always points to the latest built image.
- Automated CI/CD for Go microservice
- Enforces best DevOps practices (build → test → lint → containerize → deploy)
- GitOps-style auto update for Kubernetes manifests
- Eliminates manual image tagging and deployment steps
✅ With this setup, every PR ensures production-ready builds, and your Kubernetes cluster always runs the latest tested image.