GitHub - pipedream repo - Label -> action mapping
@pd
code:
data:privatelast updated:2 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 1,000,000+ developers using the Pipedream platform
steps.
trigger
active
last updated:-last event:-
steps.
filter
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
}
5
if (steps.trigger.event.action !== 'labeled') {
  $end("Not a labeled issue. Exiting")
}
steps.
CONSTANTS
auth
to use OAuth tokens and API keys in code via theauths object
params
Owner
 
string ·params.owner
Repo
 
string ·params.repo
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) => {
1
2
3
}
4
this.owner = params.owner
this.repo = params.repo
steps.
map_label_to_action
auth
to use OAuth tokens and API keys in code via theauths object
(auths.github)
(auths.slack)
(auths.aws)
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
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
}
152
const { WebClient } = require('@slack/web-api')
const web = new WebClient(auths.slack.oauth_access_token)

// v2 projects use the GraphQL API
const { graphql } = require("@octokit/graphql");
const graphqlWithAuth = graphql.defaults({
  headers: {
    authorization: `token ${auths.github.oauth_access_token}`,
  },
});

const { Octokit } = require("@octokit/rest");
const octokit = new Octokit({
  auth: auths.github.oauth_access_token,
})

const { number: issue_number } = steps.trigger.event.issue
const opts = { ...steps.CONSTANTS, issue_number }

let numDays;
let channel = process.env.DEV_REL_ENG_SLACK_SUPPORT_CHANNEL

switch (steps.trigger.event.label.name) {
  case 'actions-docs':
    await octokit.rest.issues.createComment({
      ...opts,
      body: `Thanks for the request! Did you know that anyone can [author and publish their own Pipedream actions](https://pipedream.com/docs/components/quickstart/nodejs/actions/)? Would you be interested in helping out with that? We're happy to answer any questions or support you in any way.

If you don't have the time, would you be willing to reach out to the app provider to see if they're interested in building these? When we work with an app partner, it improves the quality of the integration, and it helps when this kind of request comes from a customer like you.`,
    });
    await octokit.rest.issues.addLabels({
      ...opts,
      labels: ["requested user help with component"]
    })
    break;
  case 'source-docs':
    await octokit.rest.issues.createComment({
      ...opts,
      body: `Thanks for the request! Did you know that anyone can [author and publish their own Pipedream sources](https://pipedream.com/docs/components/quickstart/nodejs/sources/)? Would you be interested in helping out with that? We're happy to answer any questions or support you in any way.

If you don't have the time, would you be willing to reach out to the app provider to see if they're interested in building these? When we work with an app partner, it improves the quality of the integration, and it helps when this kind of request comes from a customer like you.`,
    });
    await octokit.rest.issues.addLabels({
      ...opts,
      labels: ["requested user help with component"]
    })
    break;
  case 'actions-and-sources-docs':
    await octokit.rest.issues.createComment({
      ...opts,
      body: `Thanks for the request! Did you know that anyone can [author and publish their own Pipedream actions](https://pipedream.com/docs/components/quickstart/nodejs/actions/) and [sources](https://pipedream.com/docs/components/quickstart/nodejs/sources/)? Would you be interested in helping out with that? We're happy to answer any questions or support you in any way.

If you don't have the time, would you be willing to reach out to the app provider to see if they're interested in building these? When we work with an app partner, it improves the quality of the integration, and it helps when this kind of request comes from a customer like you.`,
    });
    await octokit.rest.issues.addLabels({
      ...opts,
      labels: ["requested user help with component"]
    })
    break;
  case 'app':
    await web.chat.postMessage({
      text: `New app request: <${steps.trigger.event.issue.html_url}|${steps.trigger.event.issue.title}>`,
      channel: "#app-submissions",
    })
    break;
  case 'added to app backlog':
    await graphqlWithAuth({
      query: `mutation addItemToProject(\$projectId: ID!, \$contentId: ID!) {
        addProjectNextItem(input: {projectId: \$projectId, contentId: \$contentId}) {
          projectNextItem {
            id
          }
        }
      }`,
      projectId: "PN_kwDOApw2Qs4ACb_2",
      contentId: steps.trigger.event.issue.node_id,
    });
    
    await octokit.rest.issues.createComment({
      ...opts,
      body: `Thanks for the request! We've added this to [our integrations backlog](https://github.com/orgs/PipedreamHQ/projects/8/views/1), and we'll update this ticket with progress.`
    })
    break;
  case 'remind-me-in-30':
  case 'remind-me-in-90':
    const splitLabel = steps.trigger.event.label.name.split('-')
    // e.g. remind-me-in-30 -> 30
    const numDays = splitLabel[splitLabel.length - 1]

    await web.chat.postMessage({
      text: `I'll remind you to check <${steps.trigger.event.issue.html_url}|${steps.trigger.event.issue.title}> in ${numDays} days`,
      channel,
    })
    await web.chat.scheduleMessage({
      text: `This is your ${numDays} day reminder to check on <${steps.trigger.event.issue.html_url}|${steps.trigger.event.issue.title}>`,
      channel,
      post_at: Math.floor(+new Date() / 1000) + (60 * 60 * 24 * numDays)
    })

    await octokit.rest.issues.addLabels({
      ...opts,
      labels: ["triaged"]
    })
    break;
  case 'triaged':
  // const channelId = process.env.DEV_REL_ENG_SLACK_SUPPORT_CHANNEL_ID
  // // Lookup the info for the issue in DDB
  // const { accessKeyId, secretAccessKey } = auths.aws

  // const AWS = require("aws-sdk")
  // const dynamodb = new AWS.DynamoDB.DocumentClient({
  //   accessKeyId,
  //   secretAccessKey,
  //   region: "us-east-1",
  // });

  // const { Item } = await dynamodb.get({
  //   TableName: process.env.DEV_REL_ENG_BACKLOG_GH_ISSUE_TO_CARD_MAPPING_TABLE,
  //   Key: {
  //     issueId: steps.trigger.event.issue.id,
  //   }
  // }).promise();

  // const { cardId: card_id, slackThreadId } = Item
  // if (!card_id || !slackThreadId) {
  //   break;
  // }

  // // Moves card to the Done column of the project board
  // await octokit.rest.projects.moveCard({
  //   card_id,
  //   column_id: parseInt(process.env.DEV_REL_ENG_DONE_COLUMN_ID),
  //   position: 'top',
  // });

  // await web.reactions.add({
  //   channel: channelId,
  //   name: "white_check_mark",
  //   timestamp: slackThreadId,
  // })

  // await web.chat.postMessage({
  //   text: `Issue triaged, not a support issue. Moving to done.`,
  //   channel,
  //   thread_ts: slackThreadId
  // })
  // break;
  default:
    break;
}
steps.
nodejs
auth
to use OAuth tokens and API keys in code via theauths object
(auths.slack)
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
const { WebClient } = require('@slack/web-api')
const web = new WebClient(auths.slack.oauth_access_token)

switch (steps.trigger.event.label.name) {
  case 'app':
    await web.chat.postMessage({
      text: `New app request: <${steps.trigger.event.issue.html_url}|${steps.trigger.event.issue.title}>`,
      channel: "#project-app-store",
    })
    break;
}