Module: Pipedream::Dsl::Pipeline::Github

Extended by:
Github
Included in:
Pipedream::Dsl::Pipeline, Github
Defined in:
lib/pipedream/dsl/pipeline/github.rb

Instance Method Summary collapse

Instance Method Details

#extract_repo_source(url) ⇒ Object



39
40
41
# File 'lib/pipedream/dsl/pipeline/github.rb', line 39

def extract_repo_source(url)
  url.sub('[email protected]:','').sub('https://github.com/','').sub(/\.git$/,'')
end

#github(props) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/pipedream/dsl/pipeline/github.rb', line 3

def github(props)
  # nice shorthands
  source = props.delete(:source)
  source = extract_repo_source(source)
  owner,repo = source.split("/")

  # cli option can override this in codepipe/pipeline.rb set_source!
  # so cli option always gets the highest precendence
  branch = props.delete(:branch) || "master" # always delete branch prop

  o_auth_token = props.delete(:auth_token)
  poll_for_source_changes = props.delete(:poll_for_source_changes) || "false"

  source_name = props.delete(:source_name) || "Main"

  default = {
    name: source_name,
    action_type_id: {
      category: "Source",
      owner: "ThirdParty",
      provider: "GitHub",
      version: "1",
    },
    run_order: @run_order,
    configuration: {
      branch: branch,
      o_auth_token: o_auth_token,
      owner: owner,
      poll_for_source_changes: poll_for_source_changes,
      repo: repo,
    },
    output_artifacts: [name: "#{source_name}Artifact"]
  }
  action(props.reverse_merge(default))
end