This repository serves as an example of a secure CI/CD pipeline using GitHub Actions, focused on enforcing code quality and software supply chain security. It demonstrates how to integrate automated code review, quality gates, build packaging, and container image security scanning to prevent vulnerable or low-quality code from progressing to production.

The pipeline acts as a critical security boundary, addressing risks highlighted in OWASP A03:2025 – Software Supply Chain Security (formerly Injection in previous editions). By implementing defense-in-depth controls, it mitigates threats such as vulnerable dependencies, malicious components, and insecure artifacts in the supply chain.
For more details on supply chain risks and best practices, refer to this article: Architecting Integrity: Securing the Software Supply Chain Against OWASP A03:2025.
The workflow (located in .github/workflows/) runs on push or pull requests to the main branch and includes the following stages:
-
Checkout Code
Downloads the repository code in the GitHub Actions runner. -
Code Quality Analysis with SonarQube
- Uses the SonarQube scanner to perform static code analysis.
- Detects bugs, vulnerabilities, code smells, and security hotspots.
- Enforces a Quality Gate: The pipeline fails if the gate does not pass (e.g., no new critical issues, coverage thresholds met).
- SonarQube is assumed to be a self-hosted internal server (persistent resource in your development platform). You must provide the server URL and authentication token via GitHub Secrets.
-
Build and Package
- Builds the application and creates a Docker container image (example Dockerfile included or assumed).
-
Container Security Scanning
- Scans the built Docker image using Trivy (open-source vulnerability scanner).
- Fails the pipeline on high-severity vulnerabilities (configurable thresholds).
- Ensures no known vulnerabilities or secrets are embedded in the final artifact.
Key Principle: Only code and artifacts that pass both quality and security checks are allowed to proceed. This "hard stop" on failures protects against supply chain attacks and ensures production readiness. In regulated industries (e.g., finance, healthcare), stricter thresholds can be applied.
- A running self-hosted SonarQube server accessible from GitHub Actions runners.
- GitHub Repository Secrets configured:
SONAR_TOKEN: Authentication token for SonarQube.SONAR_HOST_URL: URL of your SonarQube instance (e.g.,https://sonarqube.yourcompany.com).
- Adjust Quality Gate conditions in your SonarQube project settings.
- Modify Trivy severity thresholds in the workflow YAML (e.g., fail on
HIGHorCRITICALonly). - Extend the pipeline for deployment (e.g., push to registry only on success).
Modern software relies heavily on third-party components and automated builds, expanding the attack surface. Automated gates in CI/CD pipelines like this one:
- Prevent vulnerable dependencies from reaching production.
- Enforce consistent code quality and security standards.
- Reduce the "Security-Velocity Paradox" by integrating checks without slowing development.
This repo is intended as a template—fork it and adapt to your project's language, build tools, and security policies.
Contributions are welcome! Please open issues or pull requests for improvements, especially around multi-language support or additional security tools.
MIT License – feel free to use and modify.