Email yourself when someone stars your Github repo
@dylburger
code:
data:privatelast updated:1 year ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 100,000+ developers using the Pipedream platform
steps.
trigger
HTTP API
Deploy to generate unique URL
This workflow runs on Pipedream's servers and is triggered by HTTP / Webhook requests.
steps.
validate_webook_signature
auth
to use OAuth tokens and API keys in code via theauths object
params
Github Webhook Secret
1
string ·params.GITHUB_SECRET
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
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
}
22
// Validate the Github webhook secret
const { GITHUB_SECRET } = params

if (!("x-hub-signature" in event.headers)) {
  $end("No x-hub-signature header present in the request. Exiting.")
}
       
// Once we've confirmed we have a signature, we want to 
// validate it by generating an HMAC SHA-256 hexdigest
// and comparing that to the value of the header
// See https://developer.github.com/webhooks/securing/#validating-payloads-from-github
const crypto = require('crypto')

const payload = Buffer.from(steps.trigger.raw_event.body_b64, 'base64').toString('utf8')
const signature = 'sha1=' + crypto.createHmac('sha1', GITHUB_SECRET).update(payload).digest('hex')

// See https://stackoverflow.com/a/31096242/10795955
if (!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(event.headers["x-hub-signature"]))) {
  $end("The correct secret key was not passed in the event. Exiting!")
}
steps.
filter_ping_event
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
6
7
}
8
// The "zen" string is a bit of random Github wisdom,
// included only on the Ping Event:
// https://developer.github.com/webhooks/#ping-event
if (event.body.zen) {
  $end("Github ping event, exiting early")
}
steps.
filter_star_removed_event
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
}
6
// For now, we'll also ignore when someone unstars our repo
if (event.body.action === "deleted") {
  $end("Star removed, exiting early")
}
steps.
email_me
Customize and send an email to the email address you registered with Pipedream. The email will be sent by notifications@pipedream.com.
params
Subject
1
string ·params.subject
Text
1
string ·params.text
Optional
code
async params => {
1
2
3
4
5
6
7
8
9
}
10
const options = {
  subject: params.subject,
  text: params.text,
}
if (params.html) {
  options.html = params.html
}
$send.email(options)