CI/CD with GitHub Actions: A Minimal Setup That Works
January 17, 2025
•
2 min read
•
By Amey Lokare
🎯 Keep It Simple
CI/CD doesn't need to be complicated. Here's a minimal GitHub Actions workflow that tests, builds, and deploys—without the enterprise bloat.
✅ Basic Workflow
Start with this:
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- run: npm install
- run: npm test
- run: npm run build
That's it. Tests run on every push and PR. If tests pass, you're good to merge.
🚀 Adding Deployment
For simple deployments, add a deploy job:
deploy:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/www/app
git pull
npm install --production
pm2 restart app
⚠️ Don't Overcomplicate
You don't need:
- Complex matrix builds (unless you actually test multiple versions)
- Separate staging/production workflows (unless you have both)
- Docker builds in CI (unless you're actually deploying containers)
- Slack notifications (unless your team actually reads them)
Start simple. Add complexity only when you need it.
💡 When to Add More
Add complexity when:
- You have multiple environments (staging, production)
- You need to test on multiple platforms
- You have complex build steps
- You need approval workflows
Until then, keep it simple.
💭 My Take
A simple CI/CD pipeline that works is better than a complex one that breaks. Start minimal, add features as you need them.
GitHub Actions makes it easy to get started. Don't let perfect be the enemy of good.