go-docker-githubactions-pipeline

Lightweight demo automating Go builds through Docker and GitHub Actions with push-to-deploy via GCP Artifact Registry.

View the Project on GitHub

πŸ”„ Go + Docker + GitHub Actions CI/CD Pipeline

End-to-end CI/CD lab automating Go application builds through Docker and GitHub Actions, integrated with GCP Artifact Registry.

Built reproducible, production-style pipelines β€” from local build β†’ tag β†’ push β†’ deploy β€” and fully documented four real debugging cycles (auth, build, tag, and workflow errors).

πŸ“¦ 100% reproducible builds Β· πŸ” Automated deploys via GitHub Actions Β· 🧩 Validated artifact storage in GCP

All commands should be run using bash.


πŸš€ Project Overview

This project demonstrates a complete CI/CD workflow:

  1. Go app β€” simple program that outputs your name, date, and time.
  2. Dockerized container β€” validated locally with docker ps -a.
  3. Artifact Registry integration β€” authenticated and pushed via gcloud.

πŸ•’ Note on Timezone

Please note, time returned is in UTC. If running locally, will default to PDT, this can easily be changed to the timezone of your choice if desired in the code.


Repository Structure

β”œβ”€β”€ .github/
    └── workflows/
        β”œβ”€β”€ README.md
        └── go-dockerimage-pipeline.yaml
β”œβ”€β”€ Deployment
β”œβ”€β”€ Docs
    └── OPERATIONS_LOG.md
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ README.md
└── utc-time-date.go


🧠 What This Shows


🧩 Stack

| Layer | Tool | |β€”β€”-|β€”β€”| | Language | Go | | Containerization | Docker | | CI/CD | GitHub Actions | | Cloud | Google Cloud Platform (Artifact Registry) |


🧰 Prerequisites


βš™οΈ Reproduction Steps

1️⃣ Clone the repo

git clone https://github.com/justin-sniesak/go-docker-githubactions-pipeline.git

2️⃣ Build and run locally

docker build -t utcTimeDate:latest .

docker run utcTimeDate

Verify output:

Hello, the date is 10/11/2025, and the time is 07:45 PM.

3️⃣ Authenticate with Google Cloud, create the artifact repo serviceaccount, attach the artifact registry IAM policy binding to the service account, create the API key, then connect your GitHub repo to your GCP project

gcloud auth configure-docker

gcloud iam service-accounts create github-actions-sa \ --display-name="GitHub Actions Service Account"

gcloud projects add-iam-policy-binding <your-project> --member="serviceAccount:github-actions-sa@<your-project>.iam.gserviceaccount.com" --role="roles/artifactregistry.writer"

gcloud iam service-accounts keys create key.json \ --iam-account=github-actions-sa@<your-project>.iam.gserviceaccount.com

cat key.json

GitHub repo -> Settings -> Secrets and Variables -> New repository secret -> paste the ENTIRE JSON key file from the previous step and save

4️⃣ Push image to Artifact Registry

docker tag gotime:latest us-west1-docker.pkg.dev/<your-project>/<repo-name>/utcTimeDate:latest

docker push us-west1-docker.pkg.dev/<your-project>/<repo-name>/utcTimeDate:latest

5️⃣ GitHub Actions CI/CD

Builds Docker image

Outputs current time and date in the pipeline log

🧾 Sample Output (GitHub Actions)

Run docker run --rm utcTimeDate docker run --rm utcTimeDate shell: /usr/bin/bash -e {0} Hello, the date is 10/12/2025, and the time is 06:10 AM.

πŸ’‘ Lessons Learned

Create, authenticate to and push Docker image to GCP Artifact Registry

CI/CD pipelines don’t have to be complex to be production-grade

Debugging is part of mastery β€” not failure

πŸ› οΈ Troubleshooting

All screenshots included in repo.

Issue 1: GCP Authentication Failure

Issue 2: Docker Build Failure

Issue 3: Pipeline Failure

Issue 4: Tag and Push to GCP Failure

🏁 Author

Justin Sniesak

Infrastructure Engineer | Cloud | Kubernetes | CI/CD | Go πŸ“ Seattle, WA