| name | ci-cd-pipeline |
| description | GitHub Actions workflows, testing automation, deployment triggers. Use when: setting up CI/CD, automating tests, configuring deployments, managing workflow triggers, caching dependencies. |
| argument-hint | trigger-event, branches, test-suite |
CI/CD Pipeline
When to Use
- Setting up automated testing on pull requests
- Configuring deployment workflows
- Implementing branch protection rules
- Automating dependency updates
- Caching build artifacts
- Managing workflow triggers and conditions
What This Skill Does
Establishes GitHub Actions CI/CD workflows for CampusOS, automating linting, testing, builds, and deployments on specific branches and PR events.
Procedure
Phase 1: Workflow Configuration
- Create
.github/workflows/ directory structure
- Define workflow file:
ci-test.yml, deploy.yml, lint.yml
- Set triggers:
push: {branches: [main]}
pull_request: {branches: [main]}
schedule: {cron: '0 2 * * *'} (nightly)
- Use
on: syntax for multiple triggers:
on:
push: { branches: [main, develop] }
pull_request: { branches: [main] }
- Add environment variables at workflow level
- Specify job concurrency and runner:
runs-on: ubuntu-latest
Phase 2: Node.js & pnpm Setup
- Checkout code:
actions/checkout@v4
- Install Node.js:
actions/setup-node@v4
- Enable pnpm:
pnpm/action-setup@v2
- Install dependencies:
pnpm install --frozen-lockfile
- Cache pnpm store:
pnpm store path → actions/cache
- Cache node_modules:
.pnpm-store
Phase 3: Testing Automation
- Run linter:
pnpm lint
- Run unit tests:
pnpm test
- Generate coverage:
pnpm test --coverage
- Upload coverage to Codecov/Coveralls
- Fail job if coverage drops below threshold (80%)
- Run integration tests:
pnpm test:integration
Phase 4: Build & Artifact Management
- Build backend:
pnpm build
- Build frontend (Next.js):
pnpm build:web
- Upload build artifacts for deploy jobs
- Store build logs on failure
- Verify build output size (warn if >5MB)
- Tag build with commit SHA/timestamp
Phase 5: Deployment Triggers
- Set deployment step to run only on
main branch
- Add approval requirement:
environment: production
- Deploy to staging on
develop branch
- Deploy to production after merge to main
- Include rollback strategy (revert previous image)
- Require successful tests before deploy
Phase 6: Notifications & Status
- Report status to PR commits
- Send Slack notifications on failure
- Add GitHub status checks (required on PR)
- Comment PR with test results + coverage
- Create issue on repeated failures
- Log workflow duration and costs
Quick Reference
touch .github/workflows/ci-test.yml
pnpm exec github-actions-linter .github/workflows/*.yml
pnpm install --frozen-lockfile
pnpm lint && pnpm test
act -j test_job
gh run list --repo owner/campus-os
gh run view {RUN_ID} --log
gh workflow run ci-test.yml --ref main
Troubleshooting
| Issue | Solution |
|---|
| pnpm cache not working | Remove pnpm/action-setup@v2 line; use built-in node caching |
| Tests fail in CI, pass locally | Run pnpm install --frozen-lockfile locally; check env vars |
| Deployment job skipped | Add if: github.ref == 'refs/heads/main' condition |
| Workflow file not recognized | Ensure YAML syntax valid; check .github/workflows/ path |
| Concurrent jobs blocking | Use concurrency: {group: '${{ github.ref }}', cancel-in-progress: true} |
| Node modules too large to cache | Use --production flag; exclude devDependencies from build |