Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

Git Tutorial

Git HOME Git Intro Git Install Git Config Git Get Started Git New Files Git Staging Git Commit Git Remove and Move Git Tagging Git Stash Git History Git Diff Git Blame Git Help Git Branch Git Merge Git Workflow Git Best Practices

Git and GitHub

GitHub Get Started Git What is SSH? GitHub Add SSH GitHub Set Remote GitHub Edit Code Pull from GitHub Push to GitHub GitHub Branch Pull Branch from GitHub Push Branch to GitHub GitHub Flow GitHub Pages Git GUI Clients

Git Contribute

GitHub Fork Git Clone from GitHub GitHub Send Pull Request

Git Undo

Git Revert Git Reset Git Clean Git Amend Git Rebase Git Reflog Git Recovery

Git Advanced

Git .gitignore Git .gitattributes Git Large File Storage (LFS) Git Signing Commits/Tags Git Cherrypick & Patch Git Bisect Git Merge Conflicts Git CI/CD Git Hooks Git Submodules Git Worktree Git Remote Advanced

Git and Bitbucket

Bitbucket Get Started Bitbucket Add SSH Bitbucket Set Remote Bitbucket Edit Code Bitbucket Branch Bitbucket Pages Bitbucket Fork Git Clone from Bitbucket Bitbucket Send Pull Request

Git and GitLab

GitLab Get Started GitLab Add SSH GitLab Set Remote GitLab Edit Code GitLab Branch GitLab Pages GitLab Fork Git Clone from GitLab GitLab Send Pull Request

Git Cert

Git Certificate

Git Reference

Git Glossary

Git Exercises

Git Terminal Git Exercises Git Challenges Git Quiz Git Syllabus Git Study Plan

Git CI/CD


Share

What is CI/CD?

CI/CD stands for Continuous Integration and Continuous Deployment/Delivery.

It means your code is automatically tested and deployed every time you push.

This helps you catch bugs early and deliver features faster, with less manual work.


Why Use CI/CD?

CI/CD automates the process of testing and deploying your code. This means:

  • Find bugs before they reach users
  • Deploy changes faster and more safely
  • Reduce manual steps and mistakes
  • Get quick feedback on every push

How Does CI/CD Work with Git?

Every time you push code to your Git repository:

  • The CI/CD service (like GitHub Actions or GitLab CI) detects the change
  • It runs tests, builds your project, and can deploy automatically
  • If something fails, you get notified right away

Example Workflow

[Developer] --push--> [Git Repository] --triggers--> [CI/CD Pipeline: Test, Build, Deploy]

Popular CI/CD Services

  • GitHub Actions: Built into GitHub, uses YAML files in .github/workflows/
  • GitLab CI/CD: Built into GitLab, uses .gitlab-ci.yml
  • CircleCI: Works with GitHub/GitLab, easy setup for many languages
  • Travis CI: A hosted CI service, uses .travis.yml
  • Azure Pipelines: Works with Azure DevOps and GitHub, supports many platforms

Key CI/CD Concepts

Here are some important terms:

  • Workflow: A series of jobs that run together
  • Job: A group of steps that run together
  • Step: A single task, like checking out code or running tests
  • Runner: The computer/server that runs your jobs
  • Trigger: Decides when your workflow runs
  • Environment Variables: Settings for your workflow
  • Secrets: Passwords or API keys

Jobs

A job is a group of steps that run together. Each job runs on a runner (a server).

Example: A Job in GitHub Actions

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      # steps go here


Steps

Each step is a single task, like checking out code or running tests.

Example: Steps

steps:
  - uses: actions/checkout@v4
  - name: Run tests
    run: npm test

Runners

A runner is the computer/server that runs your jobs.

You can use the service's runners or set up your own for more control.

Example: Specify a Runner

runs-on: ubuntu-latest

Triggers

A trigger decides when your workflow runs.

Common triggers are push (every push) and pull_request (when a pull request is opened or updated).

Example: Trigger on Push or Pull Request

on:
  push:
  pull_request:

Environment Variables & Secrets

Use environment variables for settings, and secrets for passwords or API keys.

Never hardcode secrets in your code!

Example: Use a Secret

env:
  NODE_ENV: production
  API_KEY: ${{ secrets.API_KEY }}

Build Logs

CI/CD tools show logs for every job and step. Check logs to see what happened or to debug failures.

In GitHub Actions, click on a workflow run and see logs for each job/step.


Skipping CI

You can skip CI/CD for a commit by adding [skip ci] to your commit message.

This is useful for documentation or minor changes.

Example: Skip CI

git commit -m "Update docs [skip ci]"

Badges

Add a badge to your README to show CI/CD status.

This lets others see if your latest build passed.

Example: GitHub Actions Badge

![CI](https://github.com/username/repo/actions/workflows/ci.yml/badge.svg)

Example: GitHub Actions Workflow File (Explained)

# .github/workflows/ci.yml
# This file tells GitHub Actions how to run CI for your project

name: CI                 # The name of the workflow (shows up in GitHub)
on: [push]               # Trigger: run this workflow on every push
jobs:
  build:                 # Job name (can be anything)
    runs-on: ubuntu-latest   # Runner: use the latest Ubuntu server
    steps:
      - uses: actions/checkout@v4  # Step: check out your code from the repo
      - name: Run tests            # Step: give this step a name
        run: npm test              # Step: run your project's tests
  
  • name: Sets the workflow's display name in GitHub.
  • on: Decides when the workflow runs (here: every push).
  • jobs: Groups together steps that run on a runner.
  • build: The name of this job (can be anything).
  • runs-on: Picks the type of server (here: Ubuntu Linux).
  • steps: Each step does one thing, like checking out code or running tests.
  • uses: Uses a pre-made GitHub Action (here: checks out your code).
  • name: (under steps) Gives a step a label.
  • run: Runs a shell command (here: npm test to run tests).

Troubleshooting & Best Practices

  • If a build fails, check the logs for error messages.
  • Make sure your secrets and environment variables are set correctly.
  • You can rerun failed jobs from the CI/CD dashboard.
  • Check the documentation for your CI/CD service for more help.
  • Start small: automate tests first, then add deployment when ready.
  • Keep secrets out of your code and never commit API keys.
  • Use badges to show your build status in the README.

Note: CI/CD helps catch bugs early and speeds up delivery. Even small projects can benefit from automation!




Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.