auths
objectCreate a personal access token here with the read:user
scope.
The range of time (in number of days) to look back to check starred repos, e.g. enter 7
to find the repos you starred in the last week
return
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params) => {
}
const { Octokit } = require("@octokit/rest");
const octokit = new Octokit({
auth: params.personalAccessToken,
})
const stars = await octokit.request(`GET /users/${params.username}/starred`, {
headers: {
Accept: "application/vnd.github.v3.star+json" // required to get starred_at
}
})
const epochNDaysAgo = +new Date() - (params.numDaysAgo * 24 * 60 * 60 * 1000)
// export this param to make it available in the email step, as well
this.numDaysAgo = params.numDaysAgo
return stars.data.filter(star => +new Date(star.starred_at) > epochNDaysAgo)
auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
// This "exports" the data for use in future steps, which we'll reference in our email
this.subject = `${steps.fetch_stars_since_time.$return_value.length} repos starred in the past ${steps.fetch_stars_since_time.numDaysAgo} days`
this.html = steps.fetch_stars_since_time.$return_value.map(star => `<a href="${star.repo.html_url}">${star.repo.full_name}</a>`).join('<br />')
// text fallback where html isn't supported
this.text = steps.fetch_stars_since_time.$return_value.map(star => star.repo.full_name).join('\n')
async
params => {
}
const options = {
subject: params.subject,
text: params.text,
}
if (params.html) {
options.html = params.html
}
if (params.include_collaborators) {
options.include_collaborators = params.include_collaborators
}
$send.email(options)