Skip to content

Commit

Permalink
feat(codepipeline) allow creation of pipelines without trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderKnape committed Apr 19, 2019
1 parent cab71b6 commit c6a2f9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-codepipeline-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const sourceAction = new codepipeline_actions.GitHubSourceAction({
oauthToken: token.value,
outputArtifactName: 'SourceOutput', // this will be the name of the output artifact in the Pipeline
branch: 'develop', // default: 'master'
trigger: codepipeline.TriggerType.Poll // default: 'WebHook'
});
pipeline.addStage({
name: 'Source',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import codepipeline = require('@aws-cdk/aws-codepipeline');
import { SecretValue } from '@aws-cdk/cdk';

export enum TriggerType {
None,
Poll,
WebHook,
}

/**
* Construction properties of the {@link GitHubSourceAction GitHub source action}.
*/
Expand Down Expand Up @@ -39,12 +45,11 @@ export interface GitHubSourceActionProps extends codepipeline.CommonActionProps
readonly oauthToken: SecretValue;

/**
* Whether AWS CodePipeline should poll for source changes.
* If this is `false`, the Pipeline will use a webhook to detect source changes instead.
* How AWS CodePipeline should be triggered
*
* @default false
*/
readonly pollForSourceChanges?: boolean;
readonly trigger?: TriggerType;
}

/**
Expand All @@ -63,7 +68,7 @@ export class GitHubSourceAction extends codepipeline.SourceAction {
Repo: props.repo,
Branch: props.branch || "master",
OAuthToken: props.oauthToken.toString(),
PollForSourceChanges: props.pollForSourceChanges || false,
PollForSourceChanges: (props.trigger && props.trigger == TriggerType.Poll) || false,
},
outputArtifactName: props.outputArtifactName
});
Expand All @@ -72,7 +77,7 @@ export class GitHubSourceAction extends codepipeline.SourceAction {
}

protected bind(info: codepipeline.ActionBind): void {
if (!this.props.pollForSourceChanges) {
if (!this.props.trigger || (this.props.trigger && this.props.trigger == TriggerType.WebHook)) {
new codepipeline.CfnWebhook(info.scope, 'WebhookResource', {
authentication: 'GITHUB_HMAC',
authenticationConfiguration: {
Expand Down

0 comments on commit c6a2f9e

Please sign in to comment.