CI CD Deployment
CI/CD Deployment
What Is CI/CD?
CI/CD = Continuous Integration / Continuous Deployment
Simple explanation: Push code to GitHub β automatic build β automatic deployment β site goes live
Traditional workflow:
bash# Make changes # Build locally # FTP upload to server # Test in production
CI/CD workflow:
bashgit push origin main # Done! Everything else is automatic
How It Works
- You push code to GitHub/GitLab/Bitbucket
- Webhook triggers your hosting platform
- Platform pulls the latest code
- Build process runs (if needed)
- Site deploys automatically
- You get notified of success/failure
Time saved: Hours per week β Seconds per deployment
Key Concepts
Continuous Integration (CI):
- Automatically test code when pushed
- Catch errors before they reach production
- Multiple developers can work without conflicts
Continuous Deployment (CD):
- Automatically deploy to production
- No manual steps required
- Faster iteration cycles
Pipeline: The series of automated steps from code push to live deployment.
Webhook: GitHub notifies your server when code is pushed.
Common CI/CD Platforms
Platform as a Service (PaaS)
Examples: Vercel, Netlify, Sevalla, Render, Railway
How it works:
- Connect GitHub repo
- Select branch to deploy
- Platform handles everything
Pros:
- β Zero configuration
- β Automatic builds
- β Preview deployments for PRs
- β One-click rollbacks
- β Built-in CDN
Cons:
- β Higher cost (usage-based)
- β Less control
Best for: Modern web apps (React, Vue, Next.js, Astro)
VPS with Git Hooks
Examples: DigitalOcean, Linode, Hostinger VPS, AWS EC2
How it works:
- Set up Git webhook manually
- Write deployment script
- Server pulls and builds on push
Pros:
- β Full control
- β Lower cost (flat monthly rate)
- β Can customize everything
- β Better for complex setups
Cons:
- β Requires initial setup
- β Manual configuration
- β You maintain the server
Best for: Custom setups, cost-conscious projects, learning
GitHub Actions
Built into GitHub
How it works:
- Create
.github/workflows/deploy.yml - Define build and deploy steps
- Runs on GitHub's servers
Pros:
- β Free for public repos
- β Integrates perfectly with GitHub
- β Flexible and powerful
- β Can deploy anywhere
Cons:
- β YAML configuration required
- β Learning curve
Best for: Open source projects, complex workflows
Example Workflows
Static Site (Astro, Hugo, Jekyll)
Traditional:
- Edit markdown
- Run build locally
- FTP upload to server
- Hope nothing breaks
With CI/CD:
- Edit markdown
git push origin main- Done!
Node.js App
Traditional:
- Make code changes
- SSH into server
- Pull latest code
npm install- Restart server manually
With CI/CD:
git push origin main- Server automatically updates
WordPress
CI/CD is less common (theme/plugin files vs database content)
Can use for:
- Theme development
- Plugin deployment
- Config file syncing
Speed Comparison
Build tools matter:
- npm: Standard, slower
- Bun: 3x faster than npm
- pnpm: 2x faster than npm
- Yarn: Similar to npm
Static sites are fastest:
- Pre-built HTML/CSS/JS
- No server processing
- Can use global CDN
Setting Up CI/CD
Option 1: Use a PaaS (Easiest)
- Sign up (Vercel, Netlify, Sevalla)
- Connect GitHub repo
- Select branch
- Deploy
Time: 5 minutes
Option 2: VPS with Git Hooks
- SSH into server
- Install dependencies (Node.js/Bun)
- Clone repo
- Create deployment script
- Set up webhook endpoint
- Configure GitHub webhook
Time: 30-60 minutes (one-time setup)
Option 3: GitHub Actions
- Create
.github/workflows/deploy.yml - Define build steps
- Add deployment credentials
- Push to GitHub
Time: 20-40 minutes
Best Practices
Use environment variables:
- Never commit API keys
- Store secrets in platform settings
- Different values for dev/staging/production
Test before deploying:
- Run builds locally first
- Use preview deployments
- Have a rollback plan
Monitor deployments:
- Check deployment logs
- Set up notifications
- Track build times
Use branches:
mainβ productiondevelopβ staging- Feature branches β preview deployments
Common Issues
Build Fails
Check:
- Dependencies installed correctly?
- Environment variables set?
- Build command correct?
- Enough memory/CPU?
Old Version Still Showing
Check:
- Deployment actually succeeded?
- Clear CDN/browser cache
- Correct files deployed?
Slow Builds
Solutions:
- Use faster package manager (Bun > npm)
- Cache dependencies
- Optimize build process
- Reduce bundle size
Cost Comparison
PaaS platforms:
- Free tier: Often available
- Paid: $10-100+/month (usage-based)
- Best for: Small to medium traffic
VPS:
- Cost: $4-20/month (fixed)
- Best for: Predictable traffic, multiple projects
GitHub Actions:
- Free: 2,000 minutes/month (public repos)
- Paid: $0.008/minute over limit
When to Use CI/CD
Yes, use CI/CD if:
- β You deploy frequently
- β Multiple people work on the project
- β You want to catch errors early
- β You value automation
Skip CI/CD if:
- β One-page static site that never changes
- β No version control used
- β Updating once per year
Learning Resources
- GitHub Actions: https://docs.github.com/en/actions
- Vercel docs: https://vercel.com/docs
- Netlify docs: https://docs.netlify.com
- Git webhooks: https://docs.github.com/en/webhooks
- CI/CD tutorial: Search "CI/CD explained" on YouTube
Summary
CI/CD = Automation for deployments
Benefits:
- Save time
- Reduce errors
- Deploy faster
- Better collaboration
Options:
- Easy: PaaS platforms (Vercel, Netlify, Sevalla)
- Control: VPS with Git hooks
- Flexible: GitHub Actions
Get started:
- Choose a platform
- Connect your repo
- Push code
- Watch it deploy automatically
Time from push to live: 30 seconds to 3 minutes (depending on platform and build size)