Class: AWSCDK::CodePipelineActions::GitHubSourceActionProps

Inherits:
AWSCDK::Codepipeline::CommonActionProps
  • Object
show all
Defined in:
code_pipeline_actions/git_hub_source_action_props.rb

Overview

Construction properties of the GitHubSourceAction GitHub source action.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action_name:, run_order: nil, variables_namespace: nil, oauth_token:, output:, owner:, repo:, branch: nil, trigger: nil) ⇒ GitHubSourceActionProps

Returns a new instance of GitHubSourceActionProps.

Parameters:

  • action_name (String)

    The physical, human-readable name of the Action.

  • run_order (Numeric, nil) (defaults to: nil)

    The runOrder property for this Action.

  • variables_namespace (String, nil) (defaults to: nil)

    The name of the namespace to use for variables emitted by this action.

  • oauth_token (AWSCDK::SecretValue)

    A GitHub OAuth token to use for authentication.

  • output (AWSCDK::Codepipeline::Artifact)
  • owner (String)

    The GitHub account/user that owns the repo.

  • repo (String)

    The name of the repo, without the username.

  • branch (String, nil) (defaults to: nil)

    The branch to use.

  • trigger (AWSCDK::CodePipelineActions::GitHubTrigger, nil) (defaults to: nil)

    How AWS CodePipeline should be triggered.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 16

def initialize(action_name:, run_order: nil, variables_namespace: nil, oauth_token:, output:, owner:, repo:, branch: nil, trigger: nil)
  @action_name = action_name
  Jsii::Type.check_type(@action_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "actionName")
  @run_order = run_order
  Jsii::Type.check_type(@run_order, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "runOrder") unless @run_order.nil?
  @variables_namespace = variables_namespace
  Jsii::Type.check_type(@variables_namespace, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "variablesNamespace") unless @variables_namespace.nil?
  @oauth_token = oauth_token
  Jsii::Type.check_type(@oauth_token, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TZWNyZXRWYWx1ZSJ9")), "oauthToken")
  @output = output
  Jsii::Type.check_type(@output, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZXBpcGVsaW5lLkFydGlmYWN0In0=")), "output")
  @owner = owner
  Jsii::Type.check_type(@owner, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "owner")
  @repo = repo
  Jsii::Type.check_type(@repo, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "repo")
  @branch = branch
  Jsii::Type.check_type(@branch, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "branch") unless @branch.nil?
  @trigger = trigger
  Jsii::Type.check_type(@trigger, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfY29kZXBpcGVsaW5lX2FjdGlvbnMuR2l0SHViVHJpZ2dlciJ9")), "trigger") unless @trigger.nil?
end

Instance Attribute Details

#action_nameString (readonly)

The physical, human-readable name of the Action.

Note that Action names must be unique within a single Stage.

Returns:

  • (String)


42
43
44
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 42

def action_name
  @action_name
end

#branchString? (readonly)

Note:

Default: "master"

The branch to use.

Returns:

  • (String, nil)


88
89
90
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 88

def branch
  @branch
end

#oauth_tokenAWSCDK::SecretValue (readonly)

A GitHub OAuth token to use for authentication.

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)


73
74
75
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 73

def oauth_token
  @oauth_token
end

#outputAWSCDK::Codepipeline::Artifact (readonly)



75
76
77
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 75

def output
  @output
end

#ownerString (readonly)

The GitHub account/user that owns the repo.

Returns:

  • (String)


79
80
81
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 79

def owner
  @owner
end

#repoString (readonly)

The name of the repo, without the username.

Returns:

  • (String)


83
84
85
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 83

def repo
  @repo
end

#run_orderNumeric? (readonly)

Note:

Default: 1

The runOrder property for this Action.

RunOrder determines the relative order in which multiple Actions in the same Stage execute.



50
51
52
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 50

def run_order
  @run_order
end

#triggerAWSCDK::CodePipelineActions::GitHubTrigger? (readonly)

Note:

Default: GitHubTrigger.WEBHOOK

How AWS CodePipeline should be triggered.

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).



100
101
102
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 100

def trigger
  @trigger
end

#variables_namespaceString? (readonly)

Note:

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

The name of the namespace to use for variables emitted by this action.

Returns:

  • (String, nil)


55
56
57
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 55

def variables_namespace
  @variables_namespace
end

Class Method Details

.jsii_propertiesObject



102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 102

def self.jsii_properties
  {
    :action_name => "actionName",
    :run_order => "runOrder",
    :variables_namespace => "variablesNamespace",
    :oauth_token => "oauthToken",
    :output => "output",
    :owner => "owner",
    :repo => "repo",
    :branch => "branch",
    :trigger => "trigger",
  }
end

Instance Method Details

#to_jsiiObject



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'code_pipeline_actions/git_hub_source_action_props.rb', line 116

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "actionName" => @action_name,
    "runOrder" => @run_order,
    "variablesNamespace" => @variables_namespace,
    "oauthToken" => @oauth_token,
    "output" => @output,
    "owner" => @owner,
    "repo" => @repo,
    "branch" => @branch,
    "trigger" => @trigger,
  })
  result.compact
end