π A Complete Guide to CI/CD for Go Projects using GitHub Actions


π§ What is CI/CD?
Setting up a solid CI/CD pipeline is one of the most impactful steps in delivering reliable software. If youβre working with Go (Golang) and deploying using Docker Compose, GitHub Actions offers a robust, free, and easy-to-use CI/CD platform.
In this blog, Iβll walk you through setting up a real-world CI pipeline for a Go project using my open-source project GoTaskify as an example.
π§ Why CI/CD for Go?
With Goβs simplicity and GitHub Actionsβ power, you can:
Automatically test code on every push or PR
Build and run Docker containers in CI
Measure test coverage and report to Codecov
Ensure a clean and repeatable deployment process
ποΈ Folder Structure for GitHub Actions
my-go-project/
βββ .github/
β βββ workflows/
β βββ ci.yml # GitHub Actions Workflow
βββ go.mod
βββ go.sum
βββ main.go
βββ handler/
βββ task.go
π οΈ Writing Your First GitHub Actions CI Pipeline
name: GoTaskify CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build-test:
name: Build, Deploy, and Test
runs-on: ubuntu-latest
steps:
- name: β¬οΈ Checkout repository
uses: actions/checkout@v3
- name: π Set up Go 1.24.1
uses: actions/setup-go@v5
with:
go-version: '1.24.1'
- name: π₯ Install dependencies
run: go mod tidy
- name: π³ Install Docker Compose
run: sudo apt-get update && sudo apt-get install -y docker-compose
- name: π³ Build and deploy with Docker Compose
run: docker-compose up --build -d
- name: β
Run Go tests (unit/integration)
run: go test ./test/...
- name: π§ͺ Run tests with coverage
run: go test -coverprofile=coverage.out ./...
- name: π€ Upload to Codecov
uses: codecov/codecov-action@v5
with:
files: coverage.out
fail_ci_if_error: true
- name: π§Ή Shut down Docker
run: docker-compose down
π Step-by-Step Breakdown
Step | Description |
Checkout repository | Clones your code into the GitHub Actions runner |
Set up Go | Installs Go version 1.24.1 |
Install dependencies | Runs go mod tidy to fetch and clean dependencies |
Install Docker Compose | Ensures docker-compose is available for the job |
Build and Deploy | Spins up your app and services using Docker Compose |
Run Go Tests | Executes unit/integration tests inside /test/ directory |
Coverage | Generates test coverage report |
Upload to Codecov | Sends coverage report to Codecov for tracking |
Shutdown Docker | Gracefully tears down containers post-test |
In the GoTaskify project, this pipeline ensures that every pull request is tested, verified, and production-ready β all automatically.
π About the Author
Sidharth Chauhan
Backend Developer | DevOps Learner
Subscribe to my newsletter
Read articles from Sidharth chauhan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sidharth chauhan
Sidharth chauhan
π Hello! I'm Sidharth Chauhan, a passionate DevOps Engineer dedicated to automating and optimizing processes to enhance software development and deployment. With expertise in Docker, Kubernetes, CI/CD, AWS, and more, I thrive in environments that leverage cutting-edge technologies and tools.I love sharing my knowledge and experiences through blogging, and I'm always eager to connect with like-minded professionals. Whether you're looking to collaborate on a project, need help with DevOps, or just want to chat about the latest tech trends, feel free to reach out!π Connect with Me: