Create a Production-Ready GitHub Actions CI/CD Workflow
Generate a complete GitHub Actions CI/CD workflow with build, test, security scanning, multi-environment deployment, and notifications.
๐ The Prompt
You are a senior DevOps engineer specializing in GitHub Actions CI/CD pipelines. Create a comprehensive GitHub Actions workflow file for a [LANGUAGE/FRAMEWORK] project hosted in a GitHub repository.
Project Details:
- Project type: [PROJECT_TYPE] (e.g., web app, API, library)
- Programming language/framework: [LANGUAGE/FRAMEWORK]
- Deployment target: [DEPLOYMENT_TARGET] (e.g., AWS ECS, Vercel, Docker Hub, npm registry)
- Branch strategy: [BRANCH_STRATEGY] (e.g., main + develop, GitFlow, trunk-based)
Requirements โ include the following in the workflow:
1. **Trigger Configuration**: Set up appropriate triggers for push events, pull requests, and manual dispatch with input parameters for environment selection.
2. **Build & Test Job**: Include steps for dependency caching, installing dependencies, linting with [LINTER_TOOL], running unit tests, and generating a code coverage report.
3. **Security Scanning Job**: Add a step that runs dependency vulnerability scanning (e.g., Snyk, Trivy, or npm audit) and fails the pipeline if critical vulnerabilities are found.
4. **Build Artifact / Docker Image**: Build the deployable artifact or Docker image, tag it appropriately using the commit SHA and semantic version, and push it to [ARTIFACT_REGISTRY].
5. **Deployment Jobs**: Create separate deployment jobs for staging and production environments with the following:
- Environment protection rules and required approvals for production
- Environment-specific secrets and variables
- Smoke tests or health checks after deployment
- Rollback step on failure
6. **Notifications**: Send a Slack or email notification on pipeline success or failure, including a summary of what was deployed.
7. **Reusable Workflow Considerations**: Structure the workflow so common steps can be extracted into reusable workflows or composite actions.
Please output the complete YAML file(s) with inline comments explaining each section, and include a brief README section at the top (as YAML comments) explaining how to configure the required secrets and variables.
๐ก Tips for Better Results
Specify your exact deployment target and branch strategy to get a workflow that matches your real setup instead of a generic template.
List the specific secrets your project uses (API keys, registry credentials) so the generated workflow references them correctly.
After generating, validate the YAML syntax using actionlint or the GitHub Actions extension in VS Code before committing.
๐ฏ Use Cases
DevOps engineers and developers who need to set up or modernize a full CI/CD pipeline in GitHub Actions for their project, saving hours of manual YAML configuration.
๐ 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
Refactor Code for Better Performance
Get your code refactored for better performance with Big O analysis and design pattern suggestions.