CI/CD (Continuous Integration and Continuous Deployment) automates the process of integrating, testing, and deploying code. Git plays a key role in CI/CD pipelines, allowing seamless collaboration between teams.
CI/CD pipelines are defined using configuration files (commonly YAML) that describe triggers, jobs, and steps for automation.
# GitHub Actions CI/CD pipeline configuration
name: CI/CD Pipeline
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
- name: Deploy to production
run: npm run deploy
if: success()
The pipeline automatically runs when code is pushed to the main branch, installs dependencies, runs tests, and deploys the application if all steps succeed.
Code Push → Build → Test → Deploy → Monitor
This flow ensures every change is validated before reaching production.