Design a secure, fast, multi-stage GitHub Actions pipeline with caching, OIDC, and progressive delivery
## CONTEXT The user wants a production-grade CI/CD pipeline in GitHub Actions for an application in 2026. They care about fast feedback, supply-chain security, and safe deployments. Relevant capabilities: reusable workflows, composite actions, OIDC federation to cloud providers (no long-lived secrets), matrix builds, dependency and artifact caching, environments with required reviewers, and attestations/provenance (SLSA). Avoid storing cloud credentials as static secrets and avoid pull_request_target footguns. ## ROLE Act as a build and release engineer who has cut deploy times from 40 minutes to under 10 and eliminated credential leaks via OIDC. You treat the pipeline as a product with its own reliability and security requirements. ## RESPONSE GUIDELINES - Provide a complete but minimal workflow YAML, plus reusable-workflow extractions. - Use OIDC for cloud auth and show the trust-policy expectations. - Pin third-party actions by commit SHA and explain why. - Separate CI (test/build) from CD (deploy) with environment protection. - Optimize for cache hit rate and parallelism; quantify expected speedups. ## TASK CRITERIA ### 1. Pipeline Topology - Define triggers (push, pull_request, tags, manual dispatch) and concurrency controls. - Split into stages: lint, test, build, scan, package, deploy. - Use reusable workflows and composite actions to avoid duplication. - Set up a matrix for languages/versions/architectures where relevant. ### 2. Speed & Caching - Configure dependency, build, and Docker layer caching with correct keys. - Parallelize independent jobs and fail fast on cheap checks. - Use path filters and change detection to skip unaffected work. - Recommend self-hosted or larger runners only where justified. ### 3. Supply-Chain Security - Replace static cloud secrets with OIDC and least-privilege roles. - Pin actions by SHA, enable Dependabot, and add SAST/dependency scanning. - Generate SBOM and build provenance/attestations (SLSA) for artifacts. - Restrict permissions with a least-privilege GITHUB_TOKEN scope. ### 4. Deployment & Progressive Delivery - Use GitHub Environments with required reviewers and deployment gates. - Implement canary or blue/green with automated rollback on SLO breach. - Wire smoke tests and post-deploy verification. - Handle database migrations safely within the pipeline. ### 5. Observability & Governance - Emit deployment markers and metrics to the observability stack. - Add status checks, branch protection, and required reviews. - Define a rollback runbook and on-call notification on failures. ## ASK THE USER FOR - Application language/runtime, package manager, and how it is deployed today. - Target environment (cloud provider, Kubernetes, serverless, VMs). - Whether OIDC federation is set up and what cloud roles exist. - Deployment strategy preference and acceptable downtime. - Compliance or artifact-signing requirements.
Or press ⌘C to copy