GitHub ActionsCI/CDDevOps
GitHub Actions: Automate Everything
Set up CI/CD pipelines with GitHub Actions for testing, building, and deploying.
5 min read
GitHub Actions: Automate Everything
GitHub Actions lets you automate your software development workflows directly in your repository.
Basic Workflow
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm test
Matrix Builds
strategy:
matrix:
node: [18, 20, 22]
os: [ubuntu-latest, macos-latest]
Deploy to Vercel
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.ORG_ID }}
vercel-project-id: ${{ secrets.PROJECT_ID }}
Best Practices
- Cache dependencies for faster builds
- Use secrets for sensitive data
- Run tests before deployment
Automate early and often!