All Guides
GitHub Actions CI/CD Setup
Create an automated test, build and deploy pipeline with GitHub Actions.
Intermediate25 min
Setup Steps
1. Create .github/workflows/ directory in your repository
2. Create a workflow file (.github/workflows/ci.yml):
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm test
- run: npm run build3. Add a deploy job:
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to server
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/www/app
git pull
npm ci
npm run build
pm2 restart app4. Add required secrets in GitHub Settings > Secrets
5. Trigger the workflow by pushing
6. Monitor results in the Actions tab
Related Guides
Git and GitHub Setup
Install Git version control system and manage projects with GitHub.
VS Code Setup and Extensions
Install Visual Studio Code editor and enhance it with developer extensions.
Node.js App Management with PM2
Manage your Node.js applications in production with PM2 process manager.
Cloudflare DNS and CDN Setup
Add Cloudflare to your site. DNS management, CDN, DDoS protection and SSL.