A reusable AWS CDK construct for creating specialized CI/CD pipelines with built-in deployment types and optional webhook integrations.
- Multiple Deployment Types: Currently supports Vite-based website deployments
- Complete CI/CD Pipeline: Automated
Source,Build, andDeploystages - GitHub Integration: Built-in GitHub source action configuration
- S3 + CloudFront Deployment: Optimized for static website hosting
- Optional Webhook Integration: Lambda-based notifications for pipeline state changes
- Environment Variables: Support for custom build environment variables
- CloudFront Invalidation: Automatic cache invalidation after deployments
npm install @sitblueprint/pipeline-constructimport { Pipeline, DeploymentType } from "@sitblueprint/pipeline-construct";
import { Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import * as s3 from "aws-cdk-lib/aws-s3";
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
import * as cdk from "aws-cdk-lib";
export class ViteWebsiteStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
// Create S3 bucket for website hosting
const websiteBucket = new s3.Bucket(this, "WebsiteBucket", {
websiteIndexDocument: "index.html",
publicReadAccess: true,
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ACLS,
});
// Create CloudFront distribution
const distribution = new cloudfront.CloudFrontWebDistribution(
this,
"Distribution",
{
originConfigs: [
{
s3OriginSource: {
s3BucketSource: websiteBucket,
},
behaviors: [{ isDefaultBehavior: true }],
},
],
},
);
// Create the pipeline
new Pipeline(this, "VitePipeline", {
name: "MyViteWebsite",
deploymentType: DeploymentType.ViteWebsite,
githubConfig: {
githubOwner: "your-github-username",
githubRepo: "your-repo-name",
githubOAuthToken: cdk.SecretValue.secretsManager("github-token"),
githubBranch: "main", // optional, defaults to "main"
},
vite: {
bucket: websiteBucket,
distribution: distribution,
buildCommands: ["npm run build"], // optional, defaults to ["npm run build"]
env: {
// optional build environment variables
NODE_ENV: "production",
API_URL: "https://api.example.com",
},
},
webhook: {
// optional
url: "https://your-webhook-endpoint.com/notify",
},
});
}
}DeploymentType.ViteWebsite: Deploys Vite-based applications to S3 with CloudFront
bucket: S3 bucket for hosting the built websitedistribution: CloudFront distribution for CDNbuildCommands?: Custom build commands (defaults to["npm run build"])env?: Environment variables for the build process
githubOwner: GitHub repository owner/organizationgithubRepo: GitHub repository namegithubOAuthToken: GitHub OAuth token (usecdk.SecretValue)githubBranch?: Branch to track (defaults to "main")
url: Webhook endpoint URL for pipeline notifications
The Vite deployment automatically:
- Source Stage: Pulls code from the specified GitHub repository
- Build Stage:
- Uses Node.js 20 runtime
- Runs
npm cito install dependencies - Executes the specified build commands
- Caches
node_modulesfor faster subsequent builds - Outputs build artifacts from the
distdirectory
- Deploy Stage:
- Uploads built files to the S3 bucket
- Automatically invalidates CloudFront cache
- Build:
npm run build - Test:
npm test
MIT