
GitHub Actions is one of the most flexible CI/CD tools available today. Beyond basic builds and tests, you can use it for deployments, automating documentation, managing monorepos, building Docker images, and much more.
In this guide, we’ll walk through real-world GitHub Actions use cases with practical YAML examples that you can adapt for your own projects.
🔹 1. Continuous Integration (CI) for Pull Requests
Automatically run tests when someone opens or updates a pull request.
name: CI Tests
on:
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
✅ Ensures no code gets merged without passing tests.
🔹 2. Automatic Deployment to Staging
Deploy to a staging environment whenever code is merged into develop.
name: Deploy to Staging
on:
push:
branches: [develop]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm install && npm run build
- name: Deploy
run: |
ssh user@staging "cd /app && git pull && pm2 restart app"
env:
SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
🔹 3. Docker Image Build and Push
Build and push Docker images to a container registry (Docker Hub or GitHub Container Registry).
name: Docker Build
on:
push:
branches: [main]
jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Build & Push Image
run: |
docker build -t myapp:latest .
docker tag myapp:latest myuser/myapp:latest
docker push myuser/myapp:latest
🔹 4. Scheduled Jobs (Cron)
Run workflows on a schedule (e.g., nightly builds, backups, or security scans).
name: Nightly Build
on:
schedule:
- cron: "0 2 * * *" # Runs daily at 2 AM UTC
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm run build
🔹 5. Monorepo Path Filtering
Run workflows only when certain directories change.
on:
push:
paths:
- "frontend/**"
- "backend/**"
📌 Useful for large monorepos where you don’t want to trigger every workflow on every commit.
🔹 6. Notifications (Slack)
Send deployment results to a Slack channel.
- name: Notify Slack
uses: slackapi/slack-github-action@v1.24.0
with:
payload: '{"text":"✅ Production deployment succeeded!"}'
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
🔹 7. Documentation Deployment
Auto-deploy documentation (e.g., MkDocs, Docusaurus) to GitHub Pages.
name: Deploy Docs
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
✅ Key Takeaways
- GitHub Actions supports a wide range of real-world automation.
- Common use cases include:
- CI testing for PRs
- Deployments to staging/production
- Docker image builds
- Scheduled jobs
- Monorepo workflows with path filtering
- Notifications to Slack/Teams
- Automated docs deployment
By combining these patterns, you can build robust CI/CD pipelines for any project.
You Might Also Like
- 👉 Getting Started with GitHub Actions: Your First CI/CD Pipeline
- 👉 Understanding GitHub Actions Workflow Files (YAML Explained in Detail)
- 👉 GitHub Actions for Testing: Run Unit Tests Automatically
- 👉 GitHub Actions for Deployment: Automating App Releases
- 👉 GitHub Actions Secrets and Security Best Practices
- 👉 GitHub Actions Caching and Performance Optimization
🛠️ Recommended Tools for Developers & Tech Pros
Save time, boost productivity, and work smarter with these AI-powered tools I personally use and recommend:
1️⃣ CopyOwl.ai – Research & Write Smarter
Write fully referenced reports, essays, or blogs in one click.
✅ 97% satisfaction • ✅ 10+ hrs saved/week • ✅ Academic citations
2️⃣ LoopCV.pro – Build a Job-Winning Resume
Create beautiful, ATS-friendly resumes in seconds — perfect for tech roles.
✅ One-click templates • ✅ PDF/DOCX export • ✅ Interview-boosting design
3️⃣ Speechify – Listen to Any Text
Turn articles, docs, or PDFs into natural-sounding audio — even while coding.
✅ 1,000+ voices • ✅ Works on all platforms • ✅ Used by 50M+ people
4️⃣ Jobright.ai – Automate Your Job Search
An AI job-search agent that curates roles, tailors resumes, finds referrers, and can apply for jobs—get interviews faster.
✅ AI agent, not just autofill – ✅ Referral insights – ✅ Faster, personalized matching