Github CI/CD Crash Course
A step-by-step guide to automating your build, test, and deployment process using GitHub Actions.
If you’re pushing code manually and deploying by hand, it’s time to level up.
In this post, I’ll show you how to set up a simple CI/CD pipeline using GitHub Actions — the easiest way to automate testing and deployment directly from your GitHub repo.
💡 What is GitHub Actions?
GitHub Actions lets you automate workflows in your development lifecycle — from running tests and building your app to deploying it into production.
It’s built right into GitHub, so no extra setup or external tools are needed.
You define everything using a simple YAML file inside .github/workflows/.
⚙️ The Workflow Explained
Here’s a complete example that you can copy and paste
name: CI/CD with GitHub Actions
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ‘14’
- name: Install Dependencies
run: npm install
- name: Run Tests
run: npm test
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to Production
run: |
if [ ${{ needs.build.result }} = ‘success’ ]; then
echo “Deployment logic goes here”
else
echo “Build failed, skipping deployment”
fi
🔍 How It Works
1. Trigger on Push
The workflow starts automatically every time you push to the main
branch.
2. Build Job
GitHub sets up a fresh Ubuntu environment, checks out your code, installs Node.js, and runs your tests.
If the tests pass — great! The workflow moves to the next job.
3. Deploy Job
This one depends on the build
job.
It only runs if the build is successful. That ensures no bad code ever gets deployed.
🧠 Why It Matters
This simple setup:
Prevents broken builds from going live
Gives you instant feedback when tests fail
Saves time and reduces human error
Brings you closer to true Continuous Integration and Continuous Deployment
You can expand it further by adding:
Linting
Docker builds
Staging vs production environments
Notifications via Slack or email
🚀 Final Thoughts
CI/CD doesn’t have to be complex.
Start with a small workflow like this, then build on it as your project grows.
Automation is one of the best investments you can make as a developer — it frees up time, improves reliability, and lets you focus on writing great code.
Course
CI/CD with GitHub Actions
Master CI/CD pipelines with GitHub Actions, automate deployments, and implement DevOps best practices
Join our new community
We just launched our brand new community to help master software engineering and AI & Automation.
See you soon 👋🏿