# CodeCommitTrigger

How should the CodeCommit Action detect changes.

This is the type of the `CodeCommitSourceAction.trigger` property.

- Source: [`aws-codepipeline-actions/lib/codecommit/source-action.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-codepipeline-actions/lib/codecommit/source-action.ts#L17)

## Example

```ts
// Source stage: read from repository
const repo = new codecommit.Repository(stack, 'TemplateRepo', {
  repositoryName: 'template-repo',
});
const sourceOutput = new codepipeline.Artifact('SourceArtifact');
const source = new cpactions.CodeCommitSourceAction({
  actionName: 'Source',
  repository: repo,
  output: sourceOutput,
  trigger: cpactions.CodeCommitTrigger.POLL,
});
const sourceStage = {
  stageName: 'Source',
  actions: [source],
};

// Deployment stage: create and deploy changeset with manual approval
const stackName = 'OurStack';
const changeSetName = 'StagedChangeSet';

const prodStage = {
  stageName: 'Deploy',
  actions: [
    new cpactions.CloudFormationCreateReplaceChangeSetAction({
      actionName: 'PrepareChanges',
      stackName,
      changeSetName,
      adminPermissions: true,
      templatePath: sourceOutput.atPath('template.yaml'),
      runOrder: 1,
    }),
    new cpactions.ManualApprovalAction({
      actionName: 'ApproveChanges',
      runOrder: 2,
    }),
    new cpactions.CloudFormationExecuteChangeSetAction({
      actionName: 'ExecuteChanges',
      stackName,
      changeSetName,
      runOrder: 3,
    }),
  ],
};

new codepipeline.Pipeline(stack, 'Pipeline', {
  crossAccountKeys: true,
  stages: [
    sourceStage,
    prodStage,
  ],
});
```

## Members

| Member | Description |
| --- | --- |
| `NONE` | The Action will never detect changes - the Pipeline it's part of will only begin a run when explicitly started. |
| `POLL` | CodePipeline will poll the repository to detect changes. |
| `EVENTS` | CodePipeline will use CloudWatch Events to be notified of changes. |

## Referenced by

- [`CodeCommitSourceActionProps`](/v2/docs/aws-cdk-lib.aws_codepipeline_actions.CodeCommitSourceActionProps).trigger
- [`CodeCommitSourceOptions`](/v2/docs/aws-cdk-lib.pipelines.CodeCommitSourceOptions).trigger
