Skip to main content
AIDevOps
  • Learn
  • Learning Paths
  • Practice
  • Open Source
  • Books
  • Engineering

    AI DevOpsThe full map of building and operating AI servicesLLMOpsLLM deployment · evaluation · observabilityHands-on ProjectsBuild AI Agent projects

    Knowledge

    DocsTechnical documentationBlogEngineering articlesPloggerDevelopment log feed

    Validate

    Certification3-level skills certification · coming soon
AI Models
LlamaTutorial|MistralTutorial|GemmaTutorial|DeepSeekTutorial|QwenTutorial
🐳 DevOps
DevOps Intro & RoadmapLinuxDockerCI/CD|Kubernetes BasicsK8s AdvancedPrometheusGrafana
🤖 AI Applied Development
Applied AI Intro & RoadmapHugging FaceLangChainLlamaIndexLLMOps|LangGraphMCPMulti-AgentAgent Evaluation
🧠 AI Core
AI Intro & RoadmapML FundamentalsLLM Fundamentals|Python AIC++|PyTorchTensorFlowJAX
🧠 AI Agent Development
Finance AI AgentLLM API ServerStock Investing AgentAIOps AI AgentEducation AI AgentCoding AI Agent
🌱 Spring Cloud
Spring Intro & RoadmapSpring Cloud GatewaySpring BootJava|Spring AISpring SecuritySpring BatchSpring JPA
🧱 Infrastructure
Infrastructure Intro & RoadmapNginxRedis
☁️ Cloud
Cloud Intro & RoadmapAWSGCPAzureNCPCloudflare
🎨 Frontend
Frontend Intro & RoadmapJavaScriptTypeScript|ReactNext.js|VueNuxt|Electron
📱 Mobile
Mobile Intro & RoadmapKotlinAndroidFlutter
⚙️ Backend
Backend Intro & RoadmapPython BasicsFastAPIDjangoFlask|CGoGinNode.js
💾 Database
DB Intro & RoadmapCore SQLOracleMySQLPostgreSQL|MongoDBVector DB
🧪 Testing
k6JMeternGrinder
AIDevOps

Engineering AI. From Code to Production.
An engineering learning platform for building and operating AI and AI Agents

Learn

  • All Guides
  • Learning Paths
  • AI Tutorial
  • Practice
  • Books

Resources

  • AI DevOps
  • LLMOps
  • Hands-on Projects
  • Docs
  • Blog
  • Plogger
  • Open Source
  • Certification (coming soon)

Start Here

  • AI Core Roadmap
  • AI Applied Development Roadmap
  • Spring Cloud Roadmap
  • DevOps Roadmap
  • Infrastructure Roadmap

 

  • Cloud Roadmap
  • Frontend Roadmap
  • Mobile Roadmap
  • Backend Roadmap
  • Database Roadmap
© 2026 AIDevOps. All rights reserved.
Terms of ServicePrivacy PolicySitemaptestforge.kr
  1. Home
  2. Learn
  3. DevOps
  4. CI/CD
Complete guide to deployment automation for AI services — from pipelines to GitOps

CI CI/CD Complete Guide

Visitors

From the basic concepts of CI/CD through branching strategy, GitHub Actions and Jenkins pipelines, build caching, OIDC-based secret management, supply chain security (SBOM and image signing), Blue-Green and Canary progressive delivery, and GitOps (ArgoCD) — the whole flow for releasing an AI Agent service safely and quickly.

  • Intermediate
  • Updated Oct 1, 2026
  • ~13 min read
  • 14 sections
  • 11 code examples
  • Web IDE lab included
CI

CI/CD Web IDE

Run code in the browser with nothing to install and learn through step-by-step examples.

Open the Web IDE →
CI/CD pipeline designBuild speed optimization & cachingOIDC secretless authentication & supply chain securityProgressive delivery & GitOps

Related frameworks & environments

🐳Docker→☸️Kubernetes Basics→☸️K8s Advanced→🐧Linux→

Contents

0 / 17
  1. How to use this guide
  2. Architecture diagrams
  3. What is CI/CD?
  4. Pipeline design
  5. Branching strategy & triggers
  6. GitHub Actions
  7. Jenkins Pipeline
  8. Caching & build speed optimization
  9. Docker images
  10. Secret management & OIDC
  11. Quality gates
  12. Supply chain security — SBOM & image signing
  13. Progressive delivery strategies (Blue-Green, Canary)
  14. Deployment and rollback
  15. IaC pipelines — Terraform & Ansible
  16. GitOps (ArgoCD)
  17. Frequently asked questions
Contents 17 sections
  1. How to use this guide
  2. Architecture diagrams
  3. What is CI/CD?
  4. Pipeline design
  5. Branching strategy & triggers
  6. GitHub Actions
  7. Jenkins Pipeline
  8. Caching & build speed optimization
  9. Docker images
  10. Secret management & OIDC
  11. Quality gates
  12. Supply chain security — SBOM & image signing
  13. Progressive delivery strategies (Blue-Green, Canary)
  14. Deployment and rollback
  15. IaC pipelines — Terraform & Ansible
  16. GitOps (ArgoCD)
  17. Frequently asked questions

How to use this guide

How to read it

Understanding CI/CD as a real-world workflow

From the basic concepts of CI/CD through branching strategy, GitHub Actions and Jenkins pipelines, build caching, OIDC-based secret management, supply chain security (SBOM and image signing), Blue-Green and Canary progressive delivery, and GitOps (ArgoCD) — the whole flow for releasing an AI Agent service safely and quickly. Rather than listing concepts, this guide is organized so you can follow the content in the order you have to make decisions on a real project.

Key perspective

Infrastructure / operations

Rather than memorizing install commands, understand the order in which traffic, runtime, observability, and incident response connect.

CI/CD pipeline designBuild speed optimization & cachingOIDC secretless authentication & supply chain securityProgressive delivery & GitOps

Architecture diagrams

To make what you read stick, it helps to capture the flow as a picture first. The two diagrams below are reference maps you can keep coming back to while learning CI/CD.

Learning flow

Rendering diagram…

Architecture view

Rendering diagram…

What is CI/CD?

When you first open CI/CD, the big picture matters more than individual commands. This section starts with the problems the concepts ahead were created to solve.

CI (Continuous Integration) is the practice of merging the code of several developers often and building and testing automatically on every merge, to find integration problems early. CD splits into the two stages that follow: Continuous Delivery, which "keeps an artifact ready to deploy at any time", and Continuous Deployment, which "actually deploys to production automatically" with no human approval. The names are similar, but the scope of automation differs.
Rendering diagram…
TermScope of automationHuman involvement
CI (Continuous Integration)Build + automated tests on every commitReviewers decide whether to merge
Continuous DeliveryCI + keeping a deploy artifact always readyA person presses the production deploy button
Continuous DeploymentDelivery + automatic deploy to production when tests passNone (notified only on failure)

Tip

"CD" is often loosely taken to mean Continuous Deployment, but most organizations actually sit at the Continuous Delivery stage, where a person approves before the production deploy — keeping the two concepts apart lets you say precisely "how far the CD of our team is automated".

Pipeline design

Here you look at Pipeline design alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

In an AI Agent service, model response quality, RAG retrieval quality, token cost, and response latency all shift together, more so than in an ordinary web service. So CI/CD has to be more than deployment automation: an operational loop that checks code quality, model call stability, prompt regressions, and performance smoke tests together.
Rendering diagram…
StageGoalTypical checks
InstallPin dependencies and ensure reproducibilitynpm ci, uv sync, lockfile check
BuildCatch frontend/backend build failures earlynpm run build, Docker build
TestVerify the core API and Agent flowsunit test, API contract, RAG sample eval
SecurityBlock secret leaks and vulnerable imagessecret scan, npm audit, image scan
DeployRoll out to production after checking stagingsmoke test, health check, rollback point

Branching strategy & triggers

Here you look at Branching strategy & triggers alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

The branching strategy is what decides "when CI runs and when a deployment happens". The more long-lived branches there are, the bigger the conflicts and integration problems at merge time, so most teams are converging on Trunk-Based Development, where feature branches live and die within a day or two.
Rendering diagram…
StrategyCharacteristicsGood fit
Trunk-BasedFeature branches merge to main within a day or two; unfinished features hidden behind feature flagsFast release cycles; most teams with mature CI/CD (recommended)
GitHub Flowmain + feature branches, deploy as soon as the PR mergesSimple web services, small teams
GitFlowSeveral long-lived branches: main/develop/release/hotfix and so onPackaged software with a fixed release cycle (overkill these days)

Tip

  • on.pull_request is for validation before merge, on.push (branches: [main]) for deployment after merge, on.workflow_dispatch for manual runs, and on.schedule for periodic runs (nightly regression tests and the like) — knowing just these four trigger combinations is enough to design most pipeline structures.
  • The develop/release branches of GitFlow pile up "code waiting to be merged" for a long time, creating the paradox that real integration happens late even though CI runs often — for a new project, start with the Trunk-Based + feature flag combination by default.

A basic GitHub Actions workflow

Here you look at A basic GitHub Actions workflow alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

On PRs, only build and test run; the Docker image is built and deployed when the change merges to the main branch. An AI Agent project needs model API keys, a DB URL, and vector DB connection details, so store them separately in GitHub Secrets.
.github/workflows/ci.ymlYAML
name: CI

on:
  pull_request:
  push:
    branches: [main]

jobs:
  build-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npm run build
      - run: npm test -- --runInBand
        if: ${{ hashFiles('**/*.test.ts', '**/*.spec.ts') != '' }}

  deploy:
    needs: build-test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy
        run: ./scripts/deploy.sh
        env:
          DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
          DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
          DATABASE_URL: ${{ secrets.DATABASE_URL }}

The Jenkins Pipeline approach

Here you look at The Jenkins Pipeline approach alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

Jenkins is still powerful in organizations that need an internal network, dedicated build servers, air-gapped deployment, or approval steps. Keeping the Jenkinsfile in the repository lets you manage the build procedure as code, and Credentials can hold model API keys and registry tokens safely.
JenkinsfileGROOVY
pipeline {
  agent any

  environment {
    NODE_VERSION = '22'
    IMAGE_NAME = 'registry.example.com/aidevops-agent'
    IMAGE_TAG = "${env.GIT_COMMIT}"
  }

  options {
    timestamps()
    disableConcurrentBuilds()
    buildDiscarder(logRotator(numToKeepStr: '20'))
  }

  stages {
    stage('Checkout') {
      steps {
        checkout scm
      }
    }

    stage('Install') {
      steps {
        sh 'node --version'
        sh 'npm ci'
      }
    }

    stage('Build') {
      steps {
        sh 'npm run build'
      }
    }

    stage('Test') {
      steps {
        sh 'npm test -- --runInBand || true'
        sh 'bash scripts/ci-smoke.sh'
      }
    }

    stage('Docker Build') {
      steps {
        sh 'docker build -t $IMAGE_NAME:$IMAGE_TAG -t $IMAGE_NAME:latest .'
      }
    }

    stage('Docker Push') {
      when { branch 'main' }
      steps {
        withCredentials([usernamePassword(
          credentialsId: 'container-registry',
          usernameVariable: 'REGISTRY_USER',
          passwordVariable: 'REGISTRY_PASSWORD'
        )]) {
          sh 'echo $REGISTRY_PASSWORD | docker login registry.example.com -u $REGISTRY_USER --password-stdin'
          sh 'docker push $IMAGE_NAME:$IMAGE_TAG'
          sh 'docker push $IMAGE_NAME:latest'
        }
      }
    }

    stage('Deploy Staging') {
      when { branch 'main' }
      steps {
        sh 'ssh deploy@staging "cd /opt/aidevops-agent && docker compose pull && docker compose up -d"'
        sh 'BASE_URL=https://staging.example.com bash scripts/ci-smoke.sh'
      }
    }

    stage('Approve Production') {
      when { branch 'main' }
      steps {
        input message: 'Deploy to production?', ok: 'Deploy'
      }
    }

    stage('Deploy Production') {
      when { branch 'main' }
      steps {
        sh 'ssh deploy@prod "cd /opt/aidevops-agent && docker compose pull && docker compose up -d"'
        sh 'BASE_URL=https://www.aidevops.us bash scripts/ci-smoke.sh'
      }
    }
  }

  post {
    failure {
      echo 'Pipeline failed. Check build logs and rollback if production deploy started.'
    }
    always {
      sh 'docker image prune -f || true'
    }
  }
}
ComponentRecommended approachCaution
AgentA Jenkins node that can run DockerCheck Docker socket permissions and build isolation
CredentialsJenkins Credentials BindingNever print API keys to the logs
StagesInstall, Build, Test, Image, DeploySeparate the failure point of each stage clearly
ApprovalApprove the production deploy with an input stepApprove after the staging smoke test
RollbackThe previous image tag or kubectl rollout undoRecord the current tag before deploying

Caching & build speed optimization

Here you look at Caching & build speed optimization alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

When the CI pipeline gets slow, developers start on something else while waiting for review, and the cost of context switching grows accordingly. Simply caching dependency installs and Docker layers and splitting tests to run in parallel often brings a pipeline that took 5-10 minutes down to the 1-2 minute range.
Rendering diagram…
.github/workflows/ci.yml (caching + parallel matrix tests)YAML
jobs:
  test:
    strategy:
      matrix:
        shard: [1, 2, 3, 4]   # split the tests into 4 and run them at the same time
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm           # automatic caching keyed on the package-lock.json hash
      - run: npm ci
      - run: npm test -- --shard=${{ matrix.shard }}/4
Cache scopeProblemFix
Key too broad (e.g. just the branch name)Keeps using a stale cache even after dependencies change — causes subtle bugsAlways include the lockfile hash in the cache key
Key too narrow (e.g. the commit SHA)The cache differs on every commit, so in effect nothing is reusedInclude only values that really affect cache validity, such as the lockfile, OS, and language version

Tip

Docker image builds can also use cache-from/cache-to: type=gha to store layers in the GitHub Actions cache storage, so layers from earlier builds are reused even where runners start fresh every time.

Building and deploying Docker images

Here you look at Building and deploying Docker images alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

For production deployment, pushing a Docker image verified in CI to a registry and having the server pull that tag is more reliable than building the source code directly on the server. Using the commit SHA as the tag makes it easy to trace which code was deployed.
.github/workflows/docker.ymlYAML
name: Docker Image

on:
  push:
    branches: [main]

env:
  IMAGE_NAME: ghcr.io/${{ github.repository }}/aidevops-agent

jobs:
  docker:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: |
            ${{ env.IMAGE_NAME }}:${{ github.sha }}
            ${{ env.IMAGE_NAME }}:latest
          cache-from: type=gha
          cache-to: type=gha,mode=max

Secret management & OIDC

Here you look at Secret management & OIDC alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

If a long-lived access key such as AWS_ACCESS_KEY_ID sits in GitHub Secrets, then once it leaks it can keep being abused until you expire it. With OIDC (OpenID Connect) federation, the CI job gets short-lived credentials straight from the cloud provider, valid only for the moment it runs, so there is no cloud key to store in GitHub Secrets in the first place.
Rendering diagram…
.github/workflows/deploy.ymlYAML
permissions:
  id-token: write   # required to issue the OIDC token
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/github-actions-deployer
          aws-region: us-east-1
          # temporary credentials are issued here, with no AWS_ACCESS_KEY_ID/SECRET
      - run: aws ecs update-service --cluster prod --service api --force-new-deployment
MethodRisk if leakedExpiry
Long-lived access keyCan be abused without limit until it expiresPermanent unless rotated by hand
Short-lived OIDC tokenUsually already expired and cannot be reusedTypically 15 minutes to 1 hour

Tip

With OIDC, the trust relationship "only workflows running on this branch of this GitHub repository can assume this Role" can be scoped narrowly in the IAM configuration on the cloud side — another repository in the same organization cannot take the Role unless it is explicitly allowed.

Quality gates for AI Agents

Here you look at Quality gates for AI Agents alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

In an AI service, answer quality can get worse even when the build succeeds. At a minimum, check a fixed question set, RAG retrieval samples, a response time threshold, and a cost threshold in CI.
scripts/ci-smoke.shBASH
#!/usr/bin/env bash
set -euo pipefail

BASE_URL="${BASE_URL:-http://localhost:3000}"

curl -fsS "$BASE_URL/health"
curl -fsS "$BASE_URL/api/search?q=refund-policy" | jq '.results | length > 0'
curl -fsS -X POST "$BASE_URL/api/chat" \
  -H 'content-type: application/json' \
  -d '{"message":"Summarize the service status"}' | jq -e '.answer'

Tip

  • Keep 10-30 RAG sample questions and check that the expected documents are retrieved.
  • For PRs that change prompts, leave snapshots of representative answers so they can be reviewed.
  • Check the p95 latency of /health, /api/chat, and /api/search with a k6 smoke test.
  • Inject production secrets only through GitHub Secrets or Cloudflare/Vercel environment variables.
  • Prepare for model API outages with a fallback model, timeouts, retries, and a circuit breaker.

Supply chain security — SBOM & image signing

Here you look at Supply chain security — SBOM & image signing alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

Even when the image itself has no vulnerabilities, that does not stop a supply chain attack in which a dependency is quietly tampered with during the build, or an unverified image is deployed as-is. The core of supply chain security is recording exactly which packages at which versions are in the image with an SBOM (Software Bill of Materials), and signing the image so that just before deployment you can verify "was this image really built by our CI?".
Rendering diagram…
.github/workflows/docker.yml (SBOM generation + signing)YAML
permissions:
  contents: read
  packages: write
  id-token: write   # required for keyless signing

steps:
  - uses: docker/build-push-action@v6
    id: build
    with:
      push: true
      tags: ${{ env.IMAGE_NAME }}:${{ github.sha }}
      sbom: true             # attach the SBOM to the image

  - uses: sigstore/cosign-installer@v3
  - name: Sign the image (keyless — signed with the GitHub OIDC identity)
    run: cosign sign --yes ${{ env.IMAGE_NAME }}@${{ steps.build.outputs.digest }}
BASH
# Verify the signature right before deploying, on the deploy server/CD pipeline
cosign verify \
  --certificate-identity-regexp "https://github.com/myorg/myrepo/.*" \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  ghcr.io/myorg/myapp@sha256:abc123...

# On verification failure the exit code is non-zero, so the CD script can stop the deploy right there
Tool/conceptRole
SBOMThe list of every package and version in the image — lets you find affected images at once when a new CVE is announced
cosign sign (keyless)Signs the image with the GitHub OIDC identity — no private key to manage separately
cosign verifyConfirms before deployment that the signature came from a trusted CI pipeline

Tip

Keyless signing means you do not have to keep a private signing key somewhere, not that "there is no signature" — the signing record stays public in the Sigstore transparency log (Rekor) and can be verified later.

Progressive delivery strategies (Blue-Green, Canary)

Here you look at Progressive delivery strategies (Blue-Green, Canary) alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

Switching 100% of traffic to a new version at once means every user is affected at the same time if something is wrong. Blue-Green and Canary both implement the same goal — "expose the new version to a few first, and widen it gradually if all is well" — in different ways.
Rendering diagram…
StrategyHow it switchesProsCons
Blue-GreenSwitches traffic all at once to a verified new environmentInstant rollback (just point the traffic back)Needs double the infrastructure resources for a moment
CanarySends only part of the traffic to the new version and raises the share graduallySmall-scale verification on real traffic; small blast radius if something is wrongCompatibility (DB schema and so on) must be managed while both versions coexist
Rolling (for reference)The approach covered in the docker/kubernetes guides — replaces instances one at a timeWorks with no extra resourcesNew and old versions both take traffic during the switch

Tip

During a Canary deployment, the new and old versions often look at the same database at the same time — a schema change such as adding a column only the new version can read is safe only after the old version is completely gone.

Deployment and rollback

Here you look at Deployment and rollback alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

For production deployment, being reversible matters more than being fast at all costs. Record the current image tag before deploying, and if the health check of the new image fails, go back to the previous tag at once.
scripts/deploy.shBASH
#!/usr/bin/env bash
set -euo pipefail

APP_DIR="/opt/aidevops-agent"
IMAGE="ghcr.io/org/aidevops-agent:${GITHUB_SHA:-latest}"

ssh "$DEPLOY_USER@$DEPLOY_HOST" <<EOF
  set -euo pipefail
  cd "$APP_DIR"
  docker compose ps
  docker compose pull
  docker compose up -d
  sleep 10
  curl -fsS http://localhost:3000/health
EOF

# If you use Kubernetes:
# kubectl set image deployment/aidevops-agent app=$IMAGE
# kubectl rollout status deployment/aidevops-agent
# kubectl rollout undo deployment/aidevops-agent

IaC pipelines — Terraform & Ansible

Here you look at IaC pipelines — Terraform & Ansible alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

Where CI/CD builds and deploys application code, Terraform and Ansible manage as code the infrastructure that application runs on. Terraform is a tool for provisioning resources such as a VPC, EKS, or RDS by declaring "what state the infrastructure should be in", and Ansible is a tool that brings existing servers into line over SSH with configuration such as installing packages and distributing config files — both fit naturally into CI/CD as separate pipeline stages.
Rendering diagram…
.github/workflows/terraform.ymlYAML
jobs:
  plan:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: hashicorp/setup-terraform@v3
      - run: terraform init
      - run: terraform plan -out=tfplan   # post the result as a PR comment

  apply:
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: hashicorp/setup-terraform@v3
      - run: terraform init
      - run: terraform apply -auto-approve
      - run: ansible-playbook -i inventory/prod.ini deploy.yml
ItemTerraformAnsible
ApproachDeclarative (describes the desired end state)Procedural (describes the sequence of tasks to perform)
Main useProvisioning cloud resources (VPC, EKS, RDS, and so on)Automating configuration and deployment on existing servers
State managementTracks the current infrastructure state in a state fileNo state file — checks the target servers directly on every run

Tip

Several people running terraform apply at once can corrupt the state file, so manage state in a remote backend with locking, such as S3+DynamoDB, and automate "PR=plan, merge=apply" with Atlantis or Terraform Cloud — then infrastructure changes also leave a reviewable history, the same way as GitOps.

GitOps (ArgoCD)

Here you look at GitOps (ArgoCD) alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

Every approach so far is a "push-based" deployment, in which the CI pipeline accesses the cluster directly and runs kubectl apply or docker compose up. GitOps is the reverse, a "pull-based" approach: you declare the manifests in a Git repository as "the state this cluster should reach", and an agent running inside the cluster (ArgoCD, Flux) continuously compares that state with the real cluster and brings it into line by itself.
Rendering diagram…
argocd-application.yamlYAML
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: myapp
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/myorg/myapp-manifests.git
    targetRevision: main
    path: overlays/production
  destination:
    server: https://kubernetes.default.svc
    namespace: production
  syncPolicy:
    automated:
      prune: true       # resources deleted from Git are deleted from the cluster automatically too
      selfHeal: true     # restores the Git state automatically even if someone changes things by hand with kubectl
AspectPush-based CI/CDGitOps (pull-based)
Cluster access credentialsThe CI system must hold access rights to the clusterNo access from outside the cluster needed — smaller attack surface
Deployment historyYou have to check the CI logs separatelyThe Git commit history is the deployment history
RollbackRe-run the previous deployment scriptA single git revert syncs back to the previous state automatically
Configuration driftA manual kubectl change by someone just stays thereselfHeal reverts anything that differs from Git automatically

Tip

  • GitOps does not mean "CI goes away" — build, test, and image creation are still handled by the existing CI pipeline, and GitOps replaces only the final CD step that actually applies the result to the cluster. Splitting the two flows means the CI pipeline needs no cluster credentials at all.
  • The ArgoCD ecosystem has extensions such as ApplicationSet, which deploys to several clusters/environments from one template; Argo Rollouts, where a controller performs Blue-Green/Canary automatically; and the App of Apps pattern, which manages the ArgoCD configuration itself in Git — adopt them one at a time as the need arises.

CI/CD: frequently asked questions

What is the difference between CI and CD?

CI (continuous integration) builds and tests the code automatically on every push so problems are found early. CD means either getting that output into a deployable state (continuous delivery) or deploying it all the way to production automatically (continuous deployment). Teams usually set up CI first, automate deployment up to staging, and keep an approval step before production.

Should I choose GitHub Actions or Jenkins?

If your code is on GitHub and you do not want to run a separate server, GitHub Actions is the easy start. Jenkins can fit better when jobs must run inside a private network, when you need fine-grained control through plugins, and when people are already available to operate it. GitHub Actions can also run jobs on your own servers with self-hosted runners.

How is GitOps different from traditional CI/CD?

In the traditional approach the pipeline runs the deploy command and pushes changes into the cluster. With GitOps you declare the desired state in a Git repository, and a tool such as Argo CD or Flux runs inside the cluster, compares Git with the actual state, and reconciles them. Deployment history is the Git history, rolling back is reverting a commit, and the pipeline needs less access to the cluster.

How do I manage passwords and API keys in a pipeline?

Do not write them in the repository. Store them in the CI tool's secret store and inject them as environment variables. Keep the values out of logs, scope permissions to what is needed, and rotate them regularly. For cloud deployments, getting short-lived credentials through OIDC is safer than long-lived keys.

← Previous guideDockerNext guide →Kubernetes