Goal
Create a workflow that is secure, repeatable, and deploy-ready.
A clean workflow structure
.github/workflows/
ci.yml
deploy.yml
Keep CI separate from deploy if possible.
Key things to get right
- least privilege permissions
- secrets from GitHub Secrets (never in repo)
- cache dependencies
- run on pull_request and push to main
Minimal example (Node)
name: CI
on:
pull_request:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run lint
- run: npm run build
Deploy safety
- use environments (staging/prod)
- add manual approval for prod
- deploy only from main or tags
Next Step
Learn how to debug failures quickly and reduce pipeline downtime.