Skip to content
v2.274.0

GitHubSourceAction Class ​

Source that is provided by a GitHub repository.

Example ​

ts
// Read the secret from Secrets Manager
const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');
const sourceOutput = new codepipeline.Artifact();
const sourceAction = new codepipeline_actions.GitHubSourceAction({
  actionName: 'GitHub_Source',
  owner: 'awslabs',
  repo: 'aws-cdk',
  oauthToken: SecretValue.secretsManager('my-github-token'),
  output: sourceOutput,
  branch: 'develop', // default: 'master'
});
pipeline.addStage({
  stageName: 'Source',
  actions: [sourceAction],
});
python
# Read the secret from Secrets Manager
pipeline = codepipeline.Pipeline(self, "MyPipeline")
source_output = codepipeline.Artifact()
source_action = codepipeline_actions.GitHubSourceAction(
    action_name="GitHub_Source",
    owner="awslabs",
    repo="aws-cdk",
    oauth_token=SecretValue.secrets_manager("my-github-token"),
    output=source_output,
    branch="develop"
)
pipeline.add_stage(
    stage_name="Source",
    actions=[source_action]
)
java
// Read the secret from Secrets Manager
Pipeline pipeline = new Pipeline(this, "MyPipeline");
Artifact sourceOutput = new Artifact();
GitHubSourceAction sourceAction = GitHubSourceAction.Builder.create()
        .actionName("GitHub_Source")
        .owner("awslabs")
        .repo("aws-cdk")
        .oauthToken(SecretValue.secretsManager("my-github-token"))
        .output(sourceOutput)
        .branch("develop")
        .build();
pipeline.addStage(StageOptions.builder()
        .stageName("Source")
        .actions(List.of(sourceAction))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Read the secret from Secrets Manager
var pipeline = new Pipeline(this, "MyPipeline");
var sourceOutput = new Artifact();
var sourceAction = new GitHubSourceAction(new GitHubSourceActionProps {
    ActionName = "GitHub_Source",
    Owner = "awslabs",
    Repo = "aws-cdk",
    OauthToken = SecretValue.SecretsManager("my-github-token"),
    Output = sourceOutput,
    Branch = "develop"
});
pipeline.AddStage(new StageOptions {
    StageName = "Source",
    Actions = new [] { sourceAction }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Read the secret from Secrets Manager
pipeline := codepipeline.NewPipeline(this, jsii.String("MyPipeline"))
sourceOutput := codepipeline.NewArtifact()
sourceAction := codepipeline_actions.NewGitHubSourceAction(&GitHubSourceActionProps{
	ActionName: jsii.String("GitHub_Source"),
	Owner: jsii.String("awslabs"),
	Repo: jsii.String("aws-cdk"),
	OauthToken: awscdk.SecretValue_SecretsManager(jsii.String("my-github-token")),
	Output: sourceOutput,
	Branch: jsii.String("develop"),
})
pipeline.AddStage(&StageOptions{
	StageName: jsii.String("Source"),
	Actions: []IAction{
		sourceAction,
	},
})

Initializer ​

ts
new GitHubSourceAction(props: GitHubSourceActionProps)
python
GitHubSourceAction(props: GitHubSourceActionProps)
java
new GitHubSourceAction(GitHubSourceActionProps props)
csharp
new GitHubSourceAction(GitHubSourceActionProps props)
go
NewGitHubSourceAction(Props GitHubSourceActionProps)

Properties ​

actionPropertiesActionPropertiesaction_propertiesActionPropertiesactionPropertiesActionPropertiesActionPropertiesActionPropertiesActionPropertiesActionPropertiesrequired#
The simple properties of the Action, like its Owner, name, etc.

Note that this accessor will be called before the bind callback.

The variables emitted by this action.

Methods ​

bind(scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfigdef bind(self, scope: Construct, stage: IStage, options: ActionBindOptions) -> ActionConfigpublic ActionConfig bind(Construct scope, IStage stage, ActionBindOptions options)public ActionConfig Bind(Construct scope, IStage stage, ActionBindOptions options)func Bind(Scope Construct, Stage IStage, Options ActionBindOptions) ActionConfig#
The callback invoked when this Action is added to a Pipeline.
onStateChange(name: string, target?: IRuleTarget, options?: RuleProps): Ruledef on_state_change(self, name: str, target: typing.Optional[IRuleTarget] = None, options: typing.Optional[RuleProps] = None) -> Rulepublic Rule onStateChange(String name, IRuleTarget target, RuleProps options)public Rule OnStateChange(string name, IRuleTarget? target = null, RuleProps? options = null)func OnStateChange(Name *string, Target IRuleTarget, Options RuleProps) Rule#
Creates an Event that will be triggered whenever the state of this Action changes.