Create a random Github issue every minute in @pddemo/demo
@demo
code:
data:publiclast updated:3 years ago
today
Waiting to run first job...
This is a live workflow with public data.
Select an event to inspect the return values and logs for each step (learn more).
Sign up to customize, add steps, modify code and more.
Join 1,000,000+ developers using the Pipedream platform
steps.
trigger
Cron Scheduler
Every minute
Next Event:Sep 14, 2021, 9:27 PM
schedule
steps.
generate_fake_issue
auth
to use OAuth tokens and API keys in code via theauths object
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) => {
1
2
3
}
4
const faker = require('faker')
return faker.commerce.productName()
steps.
github_create_repo_issue
Creates an issue in a repository.
auth
(auths.github)
params
Title

The title of the issue.

{{steps.generate_fake_issue.$return_value}}
string ·params.title
Owner

Name of repository owner.

pddemo
string ·params.owner
Repo

Name of repository.

demo
string ·params.repo
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
}
20
//See the API docs here: https://developer.github.com/v3/issues/#create-an-issue
const data = {
  assignee: params.assignee,
  body: params.body,
  labels: params.labels,
  milestone: params.milestone,
  title: params.title,
}
const config = {
  method: "post",
  url: `https://api.github.com/repos/${params.owner}/${params.repo}/issues`,
  headers: {
    Authorization: `Bearer ${auths.github.oauth_access_token}`,
  },
  data,
}
return await require("@pipedreamhq/platform").axios(this, config)
steps.
get_repo_issues
auth
to use OAuth tokens and API keys in code via theauths object
(auths.github)
params
Owner

Name of repository owner.

pddemo
string ·params.owner
Repo

Name of repository.

demo
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
//See the API docs here: https://developer.github.com/v3/issues/#list-issues-for-a-repository
const config = {
  url: `https://api.github.com/repos/${params.owner}/${params.repo}/issues`,
  params: {    
    state: params.state,
    labels: params.labels,
    sort: params.sort,
    direction: params.direction,
    since: params.since,
    milestone: params.milestone,
    creator: params.creator,
    mentioned: params.mentioned,
    assignee: params.assignee,
    per_page: 100
  },
  headers: {
    Authorization: `Bearer ${auths.github.oauth_access_token}`,
  },
}
return await require("@pipedreamhq/platform").axios(this, config)
steps.
issues_to_delete
auth
to use OAuth tokens and API keys in code via theauths object
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) => {
1
2
}
3
return steps.get_repo_issues.$return_value.slice(10)
steps.
delete_old_issues
auth
to use OAuth tokens and API keys in code via theauths object
(auths.github)
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, 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
const axios = require('axios')
const data = steps.issues_to_delete.$return_value
const deletions = []

for (let i = 0; i < data.length; i++) {
  let result = await axios({
    url: `https://api.github.com/graphql`,
    method: 'post',
    headers: {
      Authorization: `Bearer ${auths.github.oauth_access_token}`,
    },
    data: { "query": `mutation DeleteIssue {
        deleteIssue(input:{issueId:"${data[i].node_id}"}) {
          clientMutationId
        }
      }`
    } 
  })
  deletions.push(result.data)
}

return deletions