GitHub - pipedream repo - Label -> action mapping
@pd
code:
data:privatelast updated:1 month ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 200,000+ developers using the Pipedream platform
steps.
trigger
New or Updated Issue (Instant)
last updated:2 months ago
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 invocations 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 invocations 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 invocations 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
const { WebClient } = require('@slack/web-api')
const web = new WebClient(auths.slack.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.`,
    });
    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.`,
    });
    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.`,
    });
    break;
  case 'app':
    await web.chat.postMessage({
      text: `New app request: <${steps.trigger.event.issue.html_url}|${steps.trigger.event.issue.title}>`,
      channel: "#apps",
    })
    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)
    })
    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 invocations 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;
}