# .github/workflows/ci.yml
name: PixelCraft CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
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 typecheck
- name: Unit & integration tests
run: npm test
- name: Build
run: npm run build
e2e-tests:
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- name: Install Playwright
run: npx playwright install
--with-deps
- name: Run E2E tests
run: npm run test:e2e
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report/
deploy-staging:
needs: e2e-tests
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run build
- name: Deploy to staging
run: |
# Deploy frontend to Vercel
# Deploy backend to Railway
env:
DEPLOY_TOKEN:
${{ secrets.DEPLOY_TOKEN }}
npm install -D husky
npx husky init
# .husky/pre-push
npm run lint && npm run typecheck
# Catches issues BEFORE they reach CI.
# Faster feedback loop: fail locally
# in seconds instead of waiting 5 min
# for CI to tell you the same thing.
GitHub → Settings → Branches → Branch protection rules → main:
✅ Require pull request before merging
✅ Require status checks to pass
→ lint-and-test
→ e2e-tests
✅ Require branches to be up to date
✅ Do not allow bypassing
// Now: nobody can push directly to main.
// Every change goes through a PR.
// Every PR must pass CI.
// Broken code cannot reach main.
git switch -c devops/PIXELCRAFT-081-ci-cd
git add .github/ .husky/ package.json
git commit -m "Add CI/CD pipeline + branch protection (PIXELCRAFT-081)"
git push origin devops/PIXELCRAFT-081-ci-cd
# PR → Watch CI run → Green ✅ → Merge
CI/CD is the automation of the software delivery pipeline.
The DevOps philosophy: remove manual steps, automate everything, fail fast. The same principle applies at every level of software engineering.