dummy-main-sync-test
@clairefro
code:
data:privatelast updated:3 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,000+ developers using the Pipedream platform
steps.
trigger
inactive
last updated:-last event:-
steps.
github_create_pull_request
auth
to use OAuth tokens and API keys in code via theauths object
(auths.github)
params
Base

The name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository.

 
string ·params.base
Head

The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch.

 
string ·params.head
Title

The title of the new pull request.

 
string ·params.title
Owner
 
string ·params.owner
Repo
 
string ·params.repo
Optional
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps, params, auths) => {
1
2
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
}
54
//See the API docs here: https://developer.github.com/v3/pulls/#create-a-pull-request
const data = {
  base: params.base,
  body: params.body,
  head: params.head,
  title: params.title,
  maintainer_can_modify: true,
}

const headers = {
  "Authorization": `Bearer ${auths.github.oauth_access_token}`,
  "Content-Type": "application/json"
}


// // get hash of master head on target repo 
// const head = await require("@pipedreamhq/platform").axios(this, {
//   method: "get",
//   url: `https://api.github.com/repos/${params.owner}/${params.repo}/git/refs/heads/master`,
//   headers,
//   data
// });

// const headHash = head.object.sha
// console.log({headHash})

// const timestamp = new Date().valueOf().toString();
// const tempBranchName = "source-sync-" + timestamp
// console.log({tempBranchName})
// // create new temp branch in target repo
// await require("@pipedreamhq/platform").axios(this, {
//   method: "post",
//   url: `https://api.github.com/repos/${params.owner}/${params.repo}/git/refs`,
//   headers,
//   data: {
//     owner: params.owner,
//     repo: params.repo,
//     ref: `refs/heads/${tempBranchName}`,
//     sha: headHash
//   }
  
// });

return await require("@pipedreamhq/platform").axios(this, {
  method: "post",
  url: `https://api.github.com/repos/${params.owner}/${params.repo}/pulls`,
  headers: {
    Authorization: `Bearer ${auths.github.oauth_access_token}`,
    "Content-Type": "application/json"
  },
  data
});