GitHub Actions CI/CD Pipeline & Caching Optimizer
Speed up slow GitHub Actions workflows with dependency caching, matrix parallelization, and security secrets.
Interactive Prompt Playground
{{WORKFLOW_YAML}}{{PAIN_POINTS}}{{RUNNER_TYPE}}You are a CI/CD Lead and GitHub Actions Optimization Specialist.
Optimize and secure the following GitHub Actions workflow:
Workflow YAML (`.github/workflows/ci.yml`):
```yaml
name: CI
on: [push, pull_request]
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install
- run: npm run lint
- run: npm test
- run: npm run build
```
Current Duration & Pain Points: Takes 14 minutes per PR; npm install and full test suite run sequentially without caching
Target Runner: Standard GitHub-hosted ubuntu-latest
Perform a comprehensive CI/CD optimization:
1. **Caching Strategy (Dependencies & Build Artifacts)**:
- Configure smart caching for package managers (npm/pnpm/yarn, Maven, Gradle, Rust cargo).
- Use Turbo/Nx or Next.js build cache restoration across runs.
2. **Parallel Matrix Execution**:
- Split monolithic test runs into parallel test shards or separate lint/test/build matrix jobs.
3. **Security & Least Privilege**:
- Enforce minimal top-level `permissions: read-all` or explicit token scopes (`contents: read`, `pull-requests: write`).
- Prevent command injection in step names or bash expressions using PR titles/branches.
4. **Concurrency & Cancel In-Progress**:
- Add `concurrency` groups to automatically cancel obsolete CI runs when new commits are pushed.
5. **Optimized Workflow Implementation**:
- Provide the complete, ultra-fast YAML file with annotations.How to Use This Prompt
- Paste your GitHub Actions workflow file.
- Specify current runtime pain points.
- Get an optimized, parallelized YAML workflow cutting run times by 60%+.
Engineering Tips & Best Practices
- Always set timeout-minutes on every job so hung tests don't consume your entire monthly GitHub Actions minutes.
What This Prompt Inspects
Key failure modes, design principles, and quality standards evaluated during execution.
Concurrency Cancellation
Cancels superseded CI runs when developers push new commits.
Native Action Caching
Uses actions/setup-node with cache: 'npm' or 'pnpm' for instant cache hits.
Least-Privilege Permissions
Restricts GITHUB_TOKEN permissions to prevent supply chain token abuse.
SprintKit Workflow Integrations
Complementary interactive tools and workflows across SprintKit to accelerate your engineering process.
Related Prompts
Explore related developer prompts in this workflow domain.
Production Dockerfile Multi-Stage Optimization & Hardening
Optimize Dockerfiles for minimal image size, non-root security, layer caching, and CVE vulnerability reduction.
Flaky Test & Async Timing Race Condition Debugger
Fix nondeterministic test failures, unhandled async promises, and race conditions in Playwright, Jest, or Vitest.
Kubernetes Deployment, HPA & Resource Limits Review
Audit Kubernetes manifests for CPU/memory requests, readiness/liveness probes, HPA, and Pod Disruption Budgets.