Loading...
Loading...
Loading...
Git workflows and GitHub Actions for lint, test, and deploy. Keep main green with automated checks on every push and PR.
Use feature branches, push to origin, and open pull requests. Merge after review and delete the branch to keep the repo tidy.
# Feature branch workflow
git checkout main
git pull origin main
git checkout -b feature/add-login
# Work and commit
git add .
git commit -m "feat(auth): add login form and validation"
git push -u origin feature/add-login
# Open PR, merge, then cleanup
git checkout main
git pull origin main
git branch -d feature/add-loginRun on push and pull_request to main/develop. Typical steps: checkout, setup Node, install deps, lint, type-check, and test. Use npm ci for reproducible installs.
# .github/workflows/ci.yml
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Type check
run: npm run build
# or: npx tsc --noEmit
- name: Test
run: npm test
# or: npm run test:ciAdd a job that runs build (and optionally deploy). For Vercel/Netlify, you can rely on their GitHub integration for preview and production deploys, or use their official actions with secrets.
# .github/workflows/deploy-preview.yml
name: Deploy Preview
on:
pull_request:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install and build
run: |
npm ci
npm run build
# Optional: deploy to Vercel/Netlify via their GitHub integration
# or use official actions (e.g. amondnet/vercel-action) with tokens in secrets