Overview
Designs complete, efficient GitHub Actions workflows for CI and CD. Includes triggers, job matrices, intelligent caching (npm/pip/pnpm/yarn), secret management, conditional execution, artifact handling, and deployment patterns to common platforms (Vercel, AWS, GCP, Fly.io, self-hosted).
When to Use This Skill
- Setting up CI for a new repository.
- Improving slow, flaky, or expensive existing pipelines.
- Adding deployment automation.
Prerequisites
- GitHub repository with Actions enabled.
- Tests, linters, and build commands already defined in package.json / Makefile / etc.
- Secrets configured in GitHub repo settings (or org level).
Steps
Define triggers (on push to main, PRs, manual, schedule for nightly).
Create jobs:
lint
test (with matrix for node versions or browsers if needed)
build
deploy (only on main, after tests pass)
Caching:
- Use
actions/cache or actions/setup-node with cache for node_modules / pnpm store.
- Cache Docker layers when building images.
Secrets & environments:
- Use
${{ secrets.VAR }}.
- Protect production deploys with Environments + required reviewers.
Conditional steps and needs: for dependency.
Reusable workflows for common patterns across repos.
Deployment examples:
- Vercel (using
vercel action or CLI).
- AWS (ECS, Lambda, S3 + CloudFront).
- Fly.io, Railway, Render, etc.
Output:
- Full
.github/workflows/ci.yml and cd.yml (or combined).
- Required secrets list.
- How to add environments.
Examples
A production-grade CI workflow with pnpm caching, parallel jobs, and a CD workflow that deploys to Vercel on main (with preview deploys on PRs) is included, plus patterns for AWS and Docker-based deploys.
Edge Cases & Error Handling
- Flaky tests: Add retry logic or quarantine jobs.
- Long builds: Use
actions/cache aggressively and consider self-hosted runners for very large repos.
- Secret leaks: Never
echo secrets; use ::add-mask::.
Verification
- Push a PR — CI runs and reports status.
- Merge to main — CD triggers and deploys successfully.
- Check Actions tab for clean logs and artifacts.
- Success: Every PR is validated, main is always deployable, deploys are automatic and safe.
References
1---2name: github-actions-pipeline3description: Creates GitHub Actions CI/CD pipelines with build, test, lint, and deploy stages. Use when setting up or improving automated workflows in GitHub.4license: Apache-2.05---67## Overview89Designs complete, efficient GitHub Actions workflows for CI and CD. Includes triggers, job matrices, intelligent caching (npm/pip/pnpm/yarn), secret management, conditional execution, artifact handling, and deployment patterns to common platforms (Vercel, AWS, GCP, Fly.io, self-hosted).1011## When to Use This Skill1213- Setting up CI for a new repository.14- Improving slow, flaky, or expensive existing pipelines.15- Adding deployment automation.1617## Prerequisites1819- GitHub repository with Actions enabled.20- Tests, linters, and build commands already defined in package.json / Makefile / etc.21- Secrets configured in GitHub repo settings (or org level).2223## Steps24251. **Define triggers** (on push to main, PRs, manual, schedule for nightly).26272. **Create jobs**:28 - `lint`29 - `test` (with matrix for node versions or browsers if needed)30 - `build`31 - `deploy` (only on main, after tests pass)32333. **Caching**:34 - Use `actions/cache` or `actions/setup-node` with cache for node_modules / pnpm store.35 - Cache Docker layers when building images.36374. **Secrets & environments**:38 - Use `${{ secrets.VAR }}`.39 - Protect production deploys with Environments + required reviewers.40415. **Conditional steps** and `needs:` for dependency.42436. **Reusable workflows** for common patterns across repos.44457. **Deployment examples**:46 - Vercel (using `vercel` action or CLI).47 - AWS (ECS, Lambda, S3 + CloudFront).48 - Fly.io, Railway, Render, etc.49508. **Output**:51 - Full `.github/workflows/ci.yml` and `cd.yml` (or combined).52 - Required secrets list.53 - How to add environments.5455## Examples5657A production-grade CI workflow with pnpm caching, parallel jobs, and a CD workflow that deploys to Vercel on main (with preview deploys on PRs) is included, plus patterns for AWS and Docker-based deploys.5859## Edge Cases & Error Handling6061- **Flaky tests**: Add retry logic or quarantine jobs.62- **Long builds**: Use `actions/cache` aggressively and consider self-hosted runners for very large repos.63- **Secret leaks**: Never `echo` secrets; use `::add-mask::`.6465## Verification66671. Push a PR — CI runs and reports status.682. Merge to main — CD triggers and deploys successfully.693. Check Actions tab for clean logs and artifacts.704. Success: Every PR is validated, main is always deployable, deploys are automatic and safe.7172## References7374- [GitHub Actions Documentation](https://docs.github.com/en/actions)75- [actions/cache](https://github.com/actions/cache)76- [Vercel GitHub Integration](https://vercel.com/docs/concepts/git/vercel-for-github)