Continuous Integration (CI) and Continuous Deployment (CD) are practices that help automate the software development and release process.
Core Concepts
- CI (Continuous Integration): Automatically building and testing code changes every time a developer pushes to the repository.
- CD (Continuous Deployment): Automatically deploying the code to a production environment after it passes the CI stage.
Example GitHub Actions Workflow
Create a file at .github/workflows/main.yml:
name: CI/CD Pipeline
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Run tests
run: npm test
This workflow will automatically run on every push to the main branch, installing dependencies, building the project, and running tests.