Synapse Solution

  • Home
  • Devops
  • 🚀 How to Set Up CI/CD Pipeline with GitHub Actions for Your Web App (2025 Guide)
May 13, 2025Web Development

🚀 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 → SettingsSecrets and VariablesActions and add:

  • SERVER_HOST – your server IP
  • SERVER_USER – e.g. ubuntu
  • SERVER_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 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.
🛡️ Is GitHub Actions secure?
Yes — just store sensitive values using GitHub secrets.

🧠 TL;DR Summary

How do I set up CI/CD using GitHub Actions?

  1. Create .github/workflows/deploy.yml
  2. Add build + deploy steps
  3. Use SSH action or connect to Netlify
  4. 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!

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents
Whatsapp Chat