Build a Complete GitHub Actions CI/CD Workflow

Create a GitHub Actions CI/CD workflow with build, test, security scanning, Docker deployment, and notifications.

๐Ÿ“ The Prompt

Design a comprehensive GitHub Actions CI/CD workflow for a [LANGUAGE/FRAMEWORK] project hosted in a GitHub repository. The workflow should automate the full pipeline from code push to deployment. **Project Details:** - Language/Framework: [LANGUAGE/FRAMEWORK] - Package manager: [PACKAGE_MANAGER] (e.g., npm, pip, maven, cargo) - Target deployment platform: [DEPLOYMENT_TARGET] (e.g., AWS ECS, Vercel, Kubernetes, Azure App Service) - Branch strategy: main branch for production, [DEV_BRANCH] for staging **Workflow Requirements:** 1. **Trigger Configuration:** - Run on push to main and [DEV_BRANCH] branches - Run on pull requests targeting main - Allow manual dispatch with an input for environment selection 2. **CI Stage (Build & Test):** - Check out code and set up [LANGUAGE/FRAMEWORK] version [VERSION] - Cache dependencies to speed up builds - Install dependencies and run linting with [LINTER_TOOL] - Execute unit tests and generate a coverage report - Run security/vulnerability scanning (e.g., Snyk, Trivy, or npm audit) - Upload test results and coverage as artifacts 3. **CD Stage (Deploy):** - Only trigger on pushes to main or [DEV_BRANCH] (not on PRs) - Build a Docker image and push to [CONTAINER_REGISTRY] with semantic version tags - Deploy to [DEPLOYMENT_TARGET] using appropriate credentials stored as GitHub Secrets - Run a post-deployment smoke test hitting [HEALTH_CHECK_URL] 4. **Notifications:** - Send a Slack or email notification on failure - Post deployment status as a commit status check 5. **Best Practices:** - Use reusable workflows or composite actions where possible - Pin action versions by SHA for security - Include concurrency groups to cancel redundant runs Provide the complete .github/workflows/ci-cd.yml file with detailed inline comments.

๐Ÿ’ก Tips for Better Results

Fill in the CONTAINER_REGISTRY placeholder with your actual registry (e.g., ghcr.io, ECR) so the generated push commands are correct. List any specific secret names you've already configured in your repo so the workflow references them accurately. Request a separate reusable workflow file if you plan to share CI logic across multiple repositories.

๐ŸŽฏ Use Cases

Development teams and DevOps engineers who want to automate their entire build-test-deploy pipeline using GitHub Actions with security and notification best practices.

๐Ÿ”— 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.