GitHub Actions CI/CD
Create and manage GitHub Actions workflows for continuous integration, testing, and deployment pipelines.
When to Use This Skill
- Creating new workflow files in
.github/workflows/ - Setting up PR validation and automated testing
- Configuring deployment pipelines (staging/production)
- Managing GitHub secrets and environment variables
- Debugging workflow failures
- Setting up manual workflow triggers or deployment approvals
Prerequisites
Required: GitHub repository with Actions enabled
Tools: GitHub CLI (gh), act (optional, for local testing)
Workflow Basics
Location: .github/workflows/<name>.yaml
Structure:
name: Workflow Name
on: [push, pull_request]
jobs:
job-name:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Hello"
Common Patterns
PR Validation
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm test
Environment Deployments
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
environment: production # Requires approval
steps:
- uses: actions/checkout@v4
- run: ./deploy.sh
Manual Triggers
on: workflow_dispatch # Shows "Run workflow" button
Secrets Management
Add: Repository Settings → Secrets → New secret
Use:
env:
API_KEY: ${{ secrets.API_KEY }}
Debugging
gh run list # List runs
gh run view <id> # View details
gh run watch # Watch real-time
gh run rerun <id> # Retry failed run
Templates & References
- PR Checks Template - Lint and test validation
- Multi-Environment Deploy - Staging/production pipeline
- Production with Approval - Manual approval workflow
- Matrix Testing - Test across versions/platforms
- Workflow Patterns - Advanced configurations
- Triggers Reference - All trigger types and options
- Troubleshooting - Common issues and solutions
Best Practices
✅ Pin action versions (@v4), cache dependencies, use environments for production
❌ Never hardcode secrets, don't use pull_request_target without understanding risks
Quick Reference
# Workflows
gh workflow list
gh workflow run <name>
# Runs
gh run list
gh run view <id>
gh run cancel <id>
# Secrets
gh secret set NAME
gh secret list
Common Actions
actions/checkout@v4- Clone repositoryactions/setup-node@v4- Setup Node.jsactions/cache@v4- Cache dependenciesactions/upload-artifact@v4- Save files
Converted and distributed by TomeVault — claim your Tome and manage your conversions.