Cc-skills-golang golang-continuous-integration
Provides CI/CD pipeline configuration using GitHub Actions for Golang projects. Covers testing, linting, SAST, security scanning, code coverage, Dependabot, Renovate, GoReleaser, code review automation, and release pipelines. Use this whenever setting up CI for a Go project, configuring workflows, adding linters or security scanners, setting up Dependabot or Renovate, automating releases, or improving an existing CI pipeline. Also use when the user wants to add quality gates to their Go project.
git clone https://github.com/samber/cc-skills-golang
T=$(mktemp -d) && git clone --depth=1 https://github.com/samber/cc-skills-golang "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/golang-continuous-integration" ~/.claude/skills/samber-cc-skills-golang-golang-continuous-integration && rm -rf "$T"
skills/golang-continuous-integration/SKILL.mdPersona: You are a Go DevOps engineer. You treat CI as a quality gate — every pipeline decision is weighed against build speed, signal reliability, and security posture.
Modes:
- Setup — adding CI to a project for the first time: start with the Quick Reference table, then generate workflows in this order: test → lint → security → release. Prefer the latest stable major version for each GitHub Action.
- Improve — auditing or extending an existing pipeline: read current workflow files first, identify gaps against the Quick Reference table, then propose targeted additions without duplicating existing steps.
Go Continuous Integration
Set up production-grade CI/CD pipelines for Go projects using GitHub Actions.
Action Versions
The versions in the examples below are reference versions that may be outdated. GitHub Actions release frequently — the current major version for each action (
actions/checkout, actions/setup-go, golangci/golangci-lint-action, codecov/codecov-action, goreleaser/goreleaser-action, etc.) may differ from what is shown here.
Quick Reference
| Stage | Tool | Purpose |
|---|---|---|
| Test | | Unit + race detection |
| Coverage | | Coverage reporting |
| Lint | | Comprehensive linting |
| Vet | | Built-in static analysis |
| SAST | , , | Security static analysis |
| Vuln scan | | Known vulnerability detection |
| Docker | | Multi-platform image builds |
| Deps | Dependabot / Renovate | Automated dependency updates |
| Release | GoReleaser | Automated binary releases |
Testing
.github/workflows/test.yml — see test.yml
Adapt the Go version matrix to match
go.mod:
go 1.23 → matrix: ["1.23", "1.24", "1.25", "1.26", "stable"] go 1.24 → matrix: ["1.24", "1.25", "1.26", "stable"] go 1.25 → matrix: ["1.25", "1.26", "stable"] go 1.26 → matrix: ["1.26", "stable"]
Use
fail-fast: false so a failure on one Go version doesn't cancel the others.
Test flags:
: CI MUST run tests with the-race
flag (catches data races — undefined behavior in Go)-race
: Randomize test order to catch inter-test dependencies-shuffle=on
: Generate coverage data-coverprofile
: Fails ifgit diff --exit-code
changes anythinggo mod tidy
Coverage Configuration
CI SHOULD enforce code coverage thresholds. Configure thresholds in
codecov.yml at the repo root — see codecov.yml
Integration Tests
.github/workflows/integration.yml — see integration.yml
Use
-count=1 to disable test caching — cached results can hide flaky service interactions.
Linting
golangci-lint MUST be run in CI on every PR. .github/workflows/lint.yml — see lint.yml
golangci-lint Configuration
Create
.golangci.yml at the root of the project. See the samber/cc-skills-golang@golang-linter skill for the recommended configuration.
Security & SAST
.github/workflows/security.yml — see security.yml
CI MUST run
govulncheck. It only reports vulnerabilities in code paths your project actually calls — unlike generic CVE scanners. CodeQL results appear in the repository's Security tab. Bearer is good at detecting sensitive data flow issues.
CodeQL Configuration
Create
.github/codeql/codeql-config.yml to use the extended security query suite — see codeql-config.yml
Available query suites:
- default: Standard security queries
- security-extended: Extra security queries with slightly lower precision
- security-and-quality: Security queries plus maintainability and reliability checks
Container Image Scanning
If the project produces Docker images, Trivy container scanning is included in the Docker workflow — see docker.yml
Dependency Management
Dependabot
.github/dependabot.yml — see dependabot.yml
Minor/patch updates are grouped into a single PR. Major updates get individual PRs since they may have breaking changes.
Auto-Merge for Dependabot
.github/workflows/dependabot-auto-merge.yml — see dependabot-auto-merge.yml
Security warning: This workflow requires
andcontents: write— these are elevated permissions that allow merging PRs and modifying repository content. Thepull-requests: writeguard restricts execution to Dependabot only. Do not remove this guard. Note thatif: github.actor == 'dependabot[bot]'checks are not fully spoof-proof — branch protection rules are the real safety net. Ensure branch protection is configured (see Repository Security Settings) with required status checks and required approvals so that auto-merge only succeeds after all checks pass, regardless of who triggered the workflow.github.actor
Renovate (alternative)
Renovate is a more mature and configurable alternative to Dependabot. It supports automerge natively, grouping, scheduling, regex managers, and monorepo-aware updates. If Dependabot feels too limited, Renovate is the go-to choice.
Install the Renovate GitHub App, then create
renovate.json at the repo root — see renovate.json
Key advantages over Dependabot:
: Automatically runsgomodTidy
after updatesgo mod tidy- Native automerge: No separate workflow needed
- Better grouping: More flexible rules for grouping PRs
- Regex managers: Can update versions in Dockerfiles, Makefiles, etc.
- Monorepo support: Handles Go workspaces and multi-module repos
Release Automation
GoReleaser automates binary builds, checksums, and GitHub Releases. The configuration varies significantly depending on the project type.
Release Workflow
.github/workflows/release.yml — see release.yml
Security warning: This workflow requires
to create GitHub Releases. It is restricted to tag pushes (contents: write) so it cannot be triggered by pull requests or branch pushes. Only users with push access to the repository can create tags.tags: ["v*"]
GoReleaser for CLI/Programs
Programs need cross-compiled binaries, archives, and optionally Docker images.
.goreleaser.yml — see goreleaser-cli.yml
GoReleaser for Libraries
Libraries don't produce binaries — they only need a GitHub Release with a changelog. Use a minimal config that skips the build.
.goreleaser.yml — see goreleaser-lib.yml
For libraries, you may not even need GoReleaser — a simple GitHub Release created via the UI or
gh release create is often sufficient.
GoReleaser for Monorepos / Multi-Binary
When a repository contains multiple commands (e.g.,
cmd/api/, cmd/worker/).
.goreleaser.yml — see goreleaser-monorepo.yml
Docker Build & Push
For projects that produce Docker images. This workflow builds multi-platform images, generates SBOM and provenance attestations, pushes to both GitHub Container Registry (GHCR) and Docker Hub, and includes Trivy container scanning.
.github/workflows/docker.yml — see docker.yml
Security warning: Permissions are scoped per job: the
job only getscontainer-scan+contents: read, while thesecurity-events: writejob getsdocker(to push to GHCR) andpackages: write+attestations: write(for provenance/SBOM signing). This ensures the scan job cannot push images even if compromised. Theid-token: writeflag is set topushon pull requests so untrusted code cannot publish images. ThefalseandDOCKERHUB_USERNAMEsecrets must be configured in the repository secrets settings — never hardcode credentials.DOCKERHUB_TOKEN
Key details:
- QEMU + Buildx: Required for multi-platform builds (
). Remove platforms you don't need.linux/amd64,linux/arm64
on PRs: Images are built but never pushed on pull requests — this validates the Dockerfile without publishing untrusted code.push: false- Metadata action: Automatically generates semver tags (
→v1.2.3
,1.2.3
,1.2
), branch tags (1
), and SHA tags.main - Provenance + SBOM:
andprovenance: mode=max
generate supply chain attestations. These requiresbom: true
andattestations: write
permissions.id-token: write - Dual registry: Pushes to both GHCR (using
, no extra secret needed) and Docker Hub (requiresGITHUB_TOKEN
+DOCKERHUB_USERNAME
secrets). Remove the Docker Hub login and image line if not needed.DOCKERHUB_TOKEN - Trivy: Scans the built image for CRITICAL and HIGH vulnerabilities and uploads results to the Security tab.
- Adapt the image names and registries to your project. For GHCR-only, remove the Docker Hub login step and the
line fromdocker.io/
.images:
Repository Security Settings
After creating workflow files, ALWAYS tell the developer to configure GitHub repository settings (branch protection, workflow permissions, secrets, environments) — see repo-security.md
Common Mistakes
| Mistake | Fix |
|---|---|
Missing in CI tests | Always use |
No | Randomize test order to catch inter-test dependencies |
| Caching integration test results | Use to disable caching |
not checked | Add step |
Missing | One Go version failing shouldn't cancel other jobs |
| Not pinning action versions | GitHub Actions MUST use pinned major versions (e.g. , not ) |
No block | Follow least-privilege per job |
| Ignoring govulncheck findings | Fix or suppress with justification |
Related Skills
See
samber/cc-skills-golang@golang-linter, samber/cc-skills-golang@golang-security, samber/cc-skills-golang@golang-testing, samber/cc-skills-golang@golang-dependency-management skills.