Skip to content
Home/Resources/Software Development/CI/CD pipeline explained
Concept ยท Software Development

CI/CD pipeline explained, with a GitHub Actions example

Younus FardeenBy Younus FardeenUpdated 1 Dec 20268 min read
Short answer

CI (continuous integration) means every code change is automatically built and tested when pushed. CD means the tested change is then delivered or deployed. A pipeline is the ordered set of automated stages: build, test, package, deploy. It catches breakage within minutes and makes releases routine instead of risky.

On this pageWhat CI and CD mean, and how delivery differs from deploymentA working GitHub Actions workflow for a Python projectPipeline stages and what each one catchesDeploy strategies: rolling, blue-green and canaryCommon pipeline failures and fixesFrequently asked questions

This page is for students building their first project who want the pipeline to be more than a copied YAML file. The workflow below was checked against GitHub's current documentation on 1 December 2026, its YAML was parsed with PyYAML, and its test command was run locally on a two-file project. It has not run on GitHub itself, so the first run in your repository is the real test.

A pipeline is the automation around Git. If you are shaky on branches and pull requests, start with the Git commands cheat sheet; to package what the pipeline ships, read Docker for beginners.

  1. 1
    Commita push or pull request triggers the run
  2. 2
    Buildinstall dependencies, compile
  3. 3
    Testunit tests, lint, security scan
  4. 4
    Packagebuild an image or artifact
  5. 5
    Deployrelease to staging, then production
A typical pipeline, left to right. Any failing stage stops the rest.

What CI and CD mean, and how delivery differs from deployment

Continuous integration is the habit of merging small changes often and having a server build and test each one automatically. Continuous delivery extends it: every change that passes is packaged and ready to release, with a person pressing the button. Continuous deployment removes the button: a passing change goes to production by itself. Atlassian's CI vs CD page covers the three terms and says CD can mean either delivery or deployment, with deployment going one step further. Where a team draws the line on manual approval varies, so ask.

So "CD" means two different things. Ask which one a team means. Most teams practise continuous delivery with a manual approval before production, and that is a perfectly good setup for a student project too.

A working GitHub Actions workflow for a Python project

GitHub Actions reads YAML files from .github/workflows/ in your repository. This one tests on two Python versions for every push to main and every pull request, and deploys only after tests pass on main. Put an app.py, a test_app.py and a requirements.txt (empty is fine) in the repository to try it.

# .github/workflows/ci.yml
name: CI

on:
  push:
    branches: [main]
  pull_request:

permissions:
  contents: read

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    strategy:
      matrix:
        python-version: ["3.11", "3.12"]
    steps:
      - uses: actions/checkout@v6
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
      - name: Run tests
        run: python -m unittest discover -v

  deploy:
    needs: test
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment: production
    steps:
      - name: Deploy
        run: echo "Replace this step with your real deploy command"
  • on sets the triggers: pushes to main and any pull request. workflow_dispatch adds a manual run button if you want one.
  • permissions: contents: read limits the automatic GITHUB_TOKEN to the minimum. GitHub's syntax page says to allow only the access required.
  • concurrency with cancel-in-progress: true cancels an older run of the same branch when you push again, saving minutes.
  • runs-on: ubuntu-latest picks a GitHub-hosted Linux runner. timeout-minutes stops a hung job from burning your allowance.
  • strategy.matrix runs the job once per Python version. actions/setup-python@v5 installs it; actions/checkout@v6 fetches your code. Both version tags are the ones in GitHub's Python guide as read on 1 December 2026; check the actions' pages for newer tags.
  • needs: test makes deploy wait for every matrix run to pass. The if limits it to pushes on main, so pull requests never deploy. environment: production lets you add required reviewers in repository settings, which gives you continuous delivery with an approval.

The test step is plain python -m unittest discover -v. Swap in pytest once you add it to requirements.txt. The Python guide is at GitHub's building and testing Python, and every key above is defined in the workflow syntax reference.

What it costs on the free plan, as of 1 December 2026

GitHub's Actions billing page says standard GitHub-hosted runners are free in public repositories and do not use up your included allowance. For private repositories the GitHub Free plan includes $12 USD of compute per month, 500 MB of artifact storage and 10 GB of cache per repository. The page says the allowance is a money amount, not a fixed number of minutes, and its own example prices a standard Linux runner at $0.006 USD per minute, so by our arithmetic $12 covers about 2,000 Linux minutes. Rates differ by runner type and can change, so check the page. Failed runs also use minutes.

Pipeline stages and what each one catches

StageWhat runsFails whenKeep it under
TriggerPush, pull request or scheduleWrong branch filter, workflow file has a YAML errorNot applicable
BuildInstall dependencies, compileMissing or unpinned dependency, wrong language versionA few minutes
Lint and formatruff, eslint, black --checkStyle or obvious bug patterns1 minute
Unit testsFast tests of your own codeA real regressionUnder 5 minutes
Integration testsCode with a real database or serviceWiring, schema or config mistakesUnder 10 minutes
Security scanDependency and secret scanningKnown-vulnerable package, committed keyRun in parallel
PackageBuild a Docker image or artifactBad Dockerfile, missing fileA few minutes
Deploy to stagingRelease to a test copy of productionConfig or migration problemAutomatic
Deploy to productionRelease to usersHealth check failsApproval, then automatic

The time budgets are our rule of thumb, not a standard. The principle behind them: slow pipelines get skipped, so keep the first feedback fast and push slow checks later. Common tools besides GitHub Actions: GitLab CI/CD (built into GitLab), Jenkins (self-hosted, open source, plugin-heavy), CircleCI (hosted) and Azure Pipelines. The concepts transfer; only the YAML changes.

Deploy strategies: rolling, blue-green and canary

A deploy strategy decides how new code replaces old code in production. The choice trades speed, cost and how fast you can undo a bad release.

StrategyHow it worksRollbackCost and catch
RecreateStop the old version, start the new oneRedeploy the old oneCheapest; brief downtime
RollingReplace instances a few at a time; old and new run together briefly. Kubernetes Deployments update this wayRoll the rollout back, again graduallyNo extra environment; both versions must work with the same database
Blue-greenTwo identical production environments. Test the new one while idle, then switch the router to itSwitch the router back, fastDouble the infrastructure; database changes still need care
CanarySend a small share of users to the new version, watch metrics, then widenRoute users back to the old versionNeeds traffic splitting and monitoring

The definitions of blue-green and canary come from Martin Fowler's BlueGreenDeployment and CanaryRelease notes, and rolling updates from the Kubernetes update tutorial, which describes incrementally replacing Pods with zero downtime. Fowler notes that databases are the hard part, especially schema changes, and suggests deploying a schema change that supports both versions first, then the new application. Make migrations backward-compatible, such as adding a column before using it, so old and new code can run at once.

Common pipeline failures and fixes

SymptomLikely causeFix
Passes locally, fails in CIDifferent language version or an unpinned dependencyPin versions; use a matrix that includes your local version
Workflow never startsFile not under .github/workflows/, YAML indentation, branch filter excludes the pushCheck the Actions tab for a parse error; fix filters
Permission denied or 403 on a steppermissions too strict for what the step writesGrant only the one permission that step needs, at job level
Secret is empty in a pull request from a forkForks do not get repository secrets by designDo not deploy from fork PRs; keep secrets out of test steps
Flaky tests, random red runsTests depend on time, order or networkFix or quarantine them; do not just re-run until green
Minutes run outLarge matrix, no concurrency, slow installCancel superseded runs, cache dependencies, trim the matrix
Deploy runs on a pull requestMissing if condition on the deploy jobGate on github.ref and the event name as above

Practise by wiring the workflow to a repo from Python projects for beginners. To go further, the DevOps engineer roadmap and DevOps project ideas list pipelines to build and show on a resume. Free options for the deploy step are in deploy a Python API free.

Frequently asked questions

What is a CI/CD pipeline in simple words?

It is an automated assembly line for software. When you push code, a server builds it, runs tests, packages it and, if everything passes, releases it. If any step fails, the line stops and you are told. It replaces manual build-and-copy steps that are slow and easy to get wrong.

What is the difference between continuous delivery and continuous deployment?

Both start after the tests pass. In continuous delivery, the change is ready to release and a person approves the final push to production. In continuous deployment there is no approval: every passing change goes live automatically. Many teams choose delivery to keep a human check.

Is GitHub Actions free?

Standard GitHub-hosted runners are free in public repositories. For private repositories, GitHub's billing page (read 1 December 2026) lists $12 USD of included compute per month on the Free plan, plus 500 MB artifact storage. Usage beyond that is billed, and rates vary by runner, so read the page before relying on it.

How do I write my first GitHub Actions workflow?

Create .github/workflows/ci.yml in your repository. Set on to push and pull_request, add a job with runs-on: ubuntu-latest, then steps: actions/checkout, a setup action for your language, install dependencies and a test command. Commit it, then open the Actions tab to see the run.

What are the most common CI/CD tools?

GitHub Actions, GitLab CI/CD, Jenkins, CircleCI and Azure Pipelines are the common ones. GitHub Actions and GitLab CI live inside the code host; Jenkins is self-hosted. For deployment to Kubernetes, tools such as Argo CD are also used. The ideas are the same everywhere.

What is the difference between blue-green and canary deployment?

Blue-green keeps two full production environments and switches all traffic at once, giving instant rollback but double the infrastructure. Canary sends only a small share of users to the new version first and widens gradually, which limits the damage of a bad release but needs traffic splitting and monitoring.

Learn this with mentors

Programmes for builders and engineers with admissions open: live classes, mentors and project work.

Continue learning

Roadmap

DevOps engineer roadmap

Linux, CI/CD, Docker, Kubernetes, cloud and monitoring in eight stages

6 min read
Concept

Docker for beginners

Image vs container vs volume, a Python Dockerfile and the licence terms

7 min read
Concept

Git and GitHub commands

Daily commands, undo recipes, merge vs rebase and your first pull request

7 min read