Design a GitHub Actions CI/CD Pipeline with Testing, Building, and Deployment

Create a production-grade GitHub Actions CI/CD pipeline with test matrix, security scanning, Docker deployment, and notifications.

๐Ÿ“ The Prompt

Generate a complete GitHub Actions CI/CD workflow file (`.github/workflows/ci-cd.yml`) for a [PROJECT_TYPE] project using [LANGUAGE_AND_FRAMEWORK]. The repository structure has [REPO_STRUCTURE_SUMMARY]. **Pipeline Requirements:** 1. **Trigger Conditions**: - Run on push to `main` and `develop` branches - Run on pull requests targeting `main` - Allow manual dispatch with an input parameter for [MANUAL_INPUT_PARAM] 2. **CI Jobs**: - **Lint & Format Check**: Run [LINTER_TOOL] and [FORMATTER_TOOL] with fail-on-warning - **Test Matrix**: Execute tests across [VERSIONS_MATRIX] (e.g., Node 18/20, Python 3.10/3.12) on ubuntu-latest - **Security Scan**: Integrate [SECURITY_TOOL] (e.g., Snyk, Trivy, CodeQL) to scan dependencies - **Build**: Compile/bundle the project and upload artifacts using `actions/upload-artifact` 3. **CD Jobs** (only on `main` push): - Build a Docker image tagged with `${{ github.sha }}` and `latest` - Push to [CONTAINER_REGISTRY] (GHCR, ECR, Docker Hub) - Deploy to [DEPLOYMENT_TARGET] (e.g., AWS ECS, Kubernetes, Vercel) using [DEPLOYMENT_METHOD] - Run a post-deployment smoke test hitting [HEALTH_CHECK_URL] 4. **Optimizations**: - Cache dependencies using the appropriate cache action - Use `concurrency` to cancel in-progress runs on the same branch - Store secrets references for [SECRET_LIST] 5. **Notifications**: Send a Slack/Discord notification on failure using a webhook stored in secrets. Include inline comments explaining each step. Use reusable workflow calls or composite actions where it reduces duplication.

๐Ÿ’ก Tips for Better Results

Specify your exact language versions and package manager (npm, yarn, pnpm, pip, poetry) for accurate caching configuration. List all required secrets upfront so the workflow references them correctly. Test the workflow on a feature branch first by temporarily adding your branch to the trigger list.

๐ŸŽฏ Use Cases

DevOps engineers and full-stack developers use this when setting up or modernizing a CI/CD pipeline for repositories that need automated testing, security checks, containerized builds, and zero-downtime deployments.

๐Ÿ”— Related Prompts

๐Ÿ’ป Coding beginner

Explain Code Like Im a Beginner

Get any code explained in plain English with line-by-line breakdowns, analogies, and learning suggestions.

๐Ÿ’ป Coding beginner

Debug My Code and Explain the Fix

Get your code debugged with clear explanations of what went wrong and why, plus the corrected version.

๐Ÿ’ป Coding intermediate

Write Unit Tests for My Code

Generate thorough unit tests covering edge cases, error handling, and both positive and negative scenarios.

๐Ÿ’ป Coding intermediate

Convert Code Between Languages

Convert code between any programming languages while maintaining idiomatic patterns and best practices.

๐Ÿ’ป Coding intermediate

Write a REST API Endpoint

Generate production-ready REST API endpoints with validation, error handling, and documentation.

๐Ÿ’ป Coding advanced

Create a GitHub Actions CI/CD Workflow for Automated Testing and Deployment

Generate a complete GitHub Actions CI/CD workflow with build, test, deploy, and notification jobs for your project.