GitOps with GitHub Actions and Kubernetes: a practical pattern for safe, automated deployments

Continuous deployment to Kubernetes is easier and safer when you combine GitHub Actions for CI with a GitOps CD engine (Argo CD or Flux) and progressive-delivery tools like Argo Rollouts. This article explains a recent, practical pattern that many teams are adopting: use Actions to build, test, and update your Git “source of truth,” and let a GitOps controller reconcile that repo into the cluster — with progressive delivery for controlled rollouts.

Why this pattern now

High-level architecture

  1. CI (GitHub Actions)
    • Build image, run tests, push image to a registry (e.g., GitHub Container Registry).
    • Update the image tag in a GitOps config repository (or create a PR against it).
  2. CD (Argo CD / Flux)
    • The GitOps operator (pull-based) detects the change in the config repo and reconciles the cluster.
  3. Progressive delivery (Argo Rollouts)
    • Rollouts or automated canaries manage traffic shifting, health checks, and automated rollbacks.

This separation keeps CI focused on producing artifacts and CD focused on delivery and cluster state management — a pattern shown in multiple end‑to‑end guides and tutorials. (teerakarna.github.io)

Concrete workflow (step-by-step)

Minimal GitHub Actions example Below is a compact example showing the CI piece: build, push, and update a Kubernetes YAML in a separate config repo. (You’ll need a PAT stored as secrets.REPO_PAT or use an image‑updater integration instead.)

jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build image run: docker build -t ghcr.io/myorg/myapp:$ . - name: Login to GHCR uses: docker/login-action@v2 with: registry: ghcr.io username: $ password: $ - name: Push image run: docker push ghcr.io/myorg/myapp:$ - name: Update config repo (bot commit) env: REPO: myorg/config-repo PAT: $ run: | git clone https://x-access-token:${PAT}@github.com/${REPO}.git cd config yq e -i “.image.tag = "$"” k8s/myapp/values.yaml git commit -am “promote image $” git push origin main ``` This action pushes a new manifest to the config repo; Argo CD will detect and apply it. Alternatively, use an Image Updater to automate tag writes without a PAT. (dev.to)

Safety and operational tips

Why choose Argo CD + Argo Rollouts (short rationale)

Wrap-up: Why this pattern works

References (selected)

This pattern — Actions produce artifacts and update Git, Argo CD/Flux pull and reconcile, and Argo Rollouts handle safe traffic shifts — gives you reproducible, observable, and controlled deployments for Kubernetes.