CI (Continuous Integration):
Automatically builds and tests your code whenever you make changes.
CD (Continuous Deployment / Delivery):
Automatically deploys your code to a server or hosting platform after it passes tests.
.github/workflows/ci.yml
name: Simple CI
on:
push:
branches:
- main
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Run Tests
run: npm test
- name: Deploy to Server
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/www/project
git pull origin main
npm install
npm run build
SSH_HOST SSH_USER SSH_KEY
${{ secrets.SSH_HOST }}