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.05compatibility: Claude Code, Codex, Gemini CLI6metadata:7 author: ai-skills8 version: "1.0"9 category: devops10 tags: github-actions, ci-cd, workflow, caching, deploy, vercel, aws11---1213## Overview1415Designs 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).1617## When to Use This Skill1819- Setting up CI for a new repository.20- Improving slow, flaky, or expensive existing pipelines.21- Adding deployment automation.2223## Prerequisites2425- GitHub repository with Actions enabled.26- Tests, linters, and build commands already defined in package.json / Makefile / etc.27- Secrets configured in GitHub repo settings (or org level).2829## Steps30311. **Define triggers** (on push to main, PRs, manual, schedule for nightly).32332. **Create jobs**:34 - `lint`35 - `test` (with matrix for node versions or browsers if needed)36 - `build`37 - `deploy` (only on main, after tests pass)38393. **Caching**:40 - Use `actions/cache` or `actions/setup-node` with cache for node_modules / pnpm store.41 - Cache Docker layers when building images.42434. **Secrets & environments**:44 - Use `${{ secrets.VAR }}`.45 - Protect production deploys with Environments + required reviewers.46475. **Conditional steps** and `needs:` for dependency.48496. **Reusable workflows** for common patterns across repos.50517. **Deployment examples**:52 - Vercel (using `vercel` action or CLI).53 - AWS (ECS, Lambda, S3 + CloudFront).54 - Fly.io, Railway, Render, etc.55568. **Output**:57 - Full `.github/workflows/ci.yml` and `cd.yml` (or combined).58 - Required secrets list.59 - How to add environments.6061## Examples6263A 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.6465## Edge Cases & Error Handling6667- **Flaky tests**: Add retry logic or quarantine jobs.68- **Long builds**: Use `actions/cache` aggressively and consider self-hosted runners for very large repos.69- **Secret leaks**: Never `echo` secrets; use `::add-mask::`.7071## Verification72731. Push a PR — CI runs and reports status.742. Merge to main — CD triggers and deploys successfully.753. Check Actions tab for clean logs and artifacts.764. Success: Every PR is validated, main is always deployable, deploys are automatic and safe.7778## References7980- [GitHub Actions Documentation](https://docs.github.com/en/actions)81- [actions/cache](https://github.com/actions/cache)82- [Vercel GitHub Integration](https://vercel.com/docs/concepts/git/vercel-for-github)