GitHubSourceActionProps Struct
Construction properties of the GitHubSourceAction GitHub source action.
| Source | aws-codepipeline-actions/lib/github/source-action.ts |
|---|
Example
// 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],
});
# 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]
)
// 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());
// 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 }
});
// 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,
},
})
Properties
Note that Action names must be unique within a single Stage.
branchoptionalstringbranchoptionalstrbranchoptionalStringBranchoptionalstringBranchoptional*string = "master" #oauthTokenSecretValueoauth_tokenSecretValueoauthTokenSecretValueOauthTokenSecretValueOauthTokenSecretValue required #notes
It is recommended to use a Secrets Manager Secret to obtain the token:
const oauth = cdk.SecretValue.secretsManager('my-github-token'); new GitHubSourceAction(this, 'GitHubAction', { oauthToken: oauth, ... });
If you rotate the value in the Secret, you must also change at least one property of the CodePipeline to force CloudFormation to re-read the secret.
The GitHub Personal Access Token should have these scopes:
- repo - to read the repository
- admin:repo_hook - if you plan to use webhooks (true by default)
runOrderoptionalnumberrun_orderoptionalint | floatrunOrderoptionalNumberRunOrderoptionaldoubleRunOrderoptional*float64 = 1 #RunOrder determines the relative order in which multiple Actions in the same Stage execute.
triggeroptionalGitHubTriggertriggeroptionalGitHubTriggertriggeroptionalGitHubTriggerTriggeroptionalGitHubTriggerTriggeroptionalGitHubTrigger = GitHubTrigger.WEBHOOK #notes
With the default value "WEBHOOK", a webhook is created in GitHub that triggers the action With "POLL", CodePipeline periodically checks the source for changes With "None", the action is not triggered through changes in the source
To use WEBHOOK, your GitHub Personal Access Token should have admin:repo_hook scope (in addition to the regular repo scope).
variablesNamespaceoptionalstringvariables_namespaceoptionalstrvariablesNamespaceoptionalStringVariablesNamespaceoptionalstringVariablesNamespaceoptional*string #Default: a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set