Package: cloudcomponents.cdk-pull-request-check
@cloudcomponents/cdk-pull-request-checkCdk component that automatically check pull requestsInstallTypeScript/JavaScript:npminstall--save@cloudcomponents/cdk-pull-request-checkPython:pipinstallcloudcomponents.cdk-pull-request-checkHow to useimport{PullRequestCheck}from'@cloudcomponents/cdk-pull-request-check';import{Stack,StackProps}from'aws-cdk-lib';import{BuildSpec}from'aws-cdk-lib/aws-codebuild';import{Repository}from'aws-cdk-lib/aws-codecommit';import{Construct}from'constructs';exportclassCodePipelineStackextendsStack{constructor(scope:Construct,id:string,props?:StackProps){super(scope,id,props);constrepository=newRepository(this,'Repository',{repositoryName:'MyRepositoryName',});//CodePipelineetc.newPullRequestCheck(this,'PullRequestCheck',{repository,buildSpec:BuildSpec.fromSourceFilename('prcheck.yml'),});}}Approval Template Rulesimport{ApprovalRuleTemplate,ApprovalRuleTemplateRepositoryAssociation}from'@cloudcomponents/cdk-pull-request-approval-rule';import{PullRequestCheck}from'@cloudcomponents/cdk-pull-request-check';import{Stack,StackProps}from'aws-cdk-lib';import{BuildSpec}from'aws-cdk-lib/aws-codebuild';import{Repository}from'aws-cdk-lib/aws-codecommit';import{Construct}from'constructs';exportclassPullRequestStackextendsStack{constructor(scope:Construct,id:string,props?:StackProps){super(scope,id,props);constrepository=newRepository(this,'Repository',{repositoryName:'pr-check-repository',});const{approvalRuleTemplateName}=newApprovalRuleTemplate(this,'ApprovalRuleTemplate',{approvalRuleTemplateName:'template-name',template:{approvers:{numberOfApprovalsNeeded:1,},},});newApprovalRuleTemplateRepositoryAssociation(this,'ApprovalRuleTemplateRepositoryAssociation',{approvalRuleTemplateName,repository,});newPullRequestCheck(this,'PullRequestCheck',{repository,buildSpec:BuildSpec.fromSourceFilename('prcheck.yml'),});}}Custom notificationsThe component comments the pull request and sets the approval state by default. Custom notifications can be set up this wayimport{PullRequestCheck}from'@cloudcomponents/cdk-pull-request-check';import{Stack,StackProps}from'aws-cdk-lib';import{BuildSpec}from'aws-cdk-lib/aws-codebuild';import{Repository}from'aws-cdk-lib/aws-codecommit';import{SnsTopic}from'aws-cdk-lib/aws-events-targets';import{Topic}from'aws-cdk-lib/aws-sns';import{EmailSubscription}from'aws-cdk-lib/aws-sns-subscriptions';import{Construct}from'constructs';exportclassCodePipelineStackextendsStack{constructor(scope:Construct,id:string,props?:StackProps){super(scope,id,props);constrepository=newRepository(this,'Repository',{repositoryName:'MyRepositoryName',description:'Some description.',//optionalproperty});//YourCodePipeline...constprCheck=newPullRequestCheck(this,'PullRequestCheck',{repository,buildSpec:BuildSpec.fromSourceFilename('buildspecs/prcheck.yml'),});constprTopic=newTopic(this,'PullRequestTopic');prTopic.addSubscription(newEmailSubscription(process.env.DEVSECOPS_TEAM_EMAILasstring),);prCheck.onCheckStarted('started',{target:newSnsTopic(prTopic),});prCheck.onCheckSucceeded('succeeded',{target:newSnsTopic(prTopic),});prCheck.onCheckFailed('failed',{target:newSnsTopic(prTopic),});}}API ReferenceSeeAPI.md.ExampleSee more completeexamples.LicenseMIT