Blog May 13, 2025
π How to Set Up CI/CD Pipeline with GitHub Actions for Your Web App (2025 Guide)
Imagine pushing code to your repoβ¦ and bam! β itβs tested, built, and deployed automatically. Thatβs what CI/CD is for. And the best part? GitHub Actions is free for most teams and works straight from your repo.
π§ What Youβll Need
| Tool | Purpose |
|---|---|
| GitHub repo | Your code lives here |
| Hosting (like Vercel, Netlify, DigitalOcean) | Where your app gets deployed |
| SSH access or deploy token | For production deployment (if not using Netlify) |
π§βπ» Step-by-Step: GitHub Actions for CI/CD
β Step 1: Create Workflow File
mkdir -p .github/workflows
touch deploy.yml
β Step 2: Add Your Workflow Script
name: π Deploy to Production
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: π§Ή Checkout Code
uses: actions/checkout@v3
- name: π οΈ Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: π¦ Install Dependencies
run: npm install
- name: π§ͺ Run Tests
run: npm test
- name: π Deploy to Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd /var/www/myapp
git pull origin main
npm install
pm2 restart app
π Step 3: Set GitHub Secrets
Go to your GitHub repo β Settings β Secrets and Variables β Actions and add:
SERVER_HOSTβ your server IPSERVER_USERβ e.g.ubuntuSERVER_SSH_KEYβ your private key (no passphrase)
π What Happens Now?
Any time you push code to main:
- GitHub pulls code
- Installs dependencies
- Runs tests
- SSH connects and deploys
π‘ Bonus: Using Vercel or Netlify?
Even easier. Just connect your GitHub repo, and it auto-deploys on push. No SSH needed!
β Common Questions
π€ What if my build takes too long?
Use
Use
actions/cache to speed it up. GitHub gives 2,000 free CI/CD minutes/month.
π₯ What if my server has downtime?
Use PM2 or Docker rolling deployments for zero-downtime updates.
Use PM2 or Docker rolling deployments for zero-downtime updates.
π‘οΈ Is GitHub Actions secure?
Yes β just store sensitive values using GitHub secrets.
Yes β just store sensitive values using GitHub secrets.
π§ TL;DR Summary
How do I set up CI/CD using GitHub Actions?
- Create
.github/workflows/deploy.yml - Add build + deploy steps
- Use SSH action or connect to Netlify
- Push code β auto-deploy. Boom. β
π§° Need Help?
At Synapse Tech Solution, we help startups and dev teams:
- Set up full DevOps pipelines
- Automate deployments
- Optimize costs on AWS, GCP, or DigitalOcean
π Visit synapsetechsolution.com
π Or drop us a message β we love solving tech puzzles!