-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to using agenda for scheduling #189
Comments
An ideal API, expanding on this Dangerfile from the Artsy Peril setup for new RFCs. import { danger } from "danger"
import { IncomingWebhook } from "@slack/client"
import { Issues } from "github-webhook-event-types"
declare const peril: any // danger/danger#351
const gh = (danger.github as any) as Issues
const issue = gh.issue
if (issue.title.includes("RFC:")) {
var url = peril.env.SLACK_RFC_WEBHOOK_URL || ""
var webhook = new IncomingWebhook(url)
webhook.send({})
// Remind us halfway, and at the end of the week to write comments
peril.runTask('mid_week_rfc_notification', 'in 3 days', issue)
peril.runTask('end_of_week_rfc_notification', 'in 7 days', issue)
} This would be hooked up inside the peril settings, where you can define your tasks and their corresponding files: {
"rules": {
"pull_request": "artsy/artsy-danger@org/all-prs.ts",
"pull_request.closed": "artsy/artsy-danger@org/closed-prs.ts"
},
"repos": {
"artsy/reaction": {
"pull_request": "danger/pr.ts"
},
"tasks": {
"mid_week_rfc_notification": "artsy/artsy-danger@tasks/rfc/mid_week.ts",
"end_of_week_rfc_notification": "artsy/artsy-danger@tasks/rfc/mid_week.ts"
}
} Here's an example task: import { peril } from "danger"
import { IncomingWebhook } from "@slack/client"
import { Issues } from "github-webhook-event-types"
const issue = peril.data as Issues
var url = peril.env.SLACK_RFC_WEBHOOK_URL || ""
var webhook = new IncomingWebhook(url)
webhook.send({ // in 3 days etc }) the issue JSON is passed from the |
Under the hood: Today: In the future: is going to have to send something back to the host process. It's probably better to make the scheduler a separate API route POST, it should take a task name, an interval and some dumb json data. Under the hood it can call agenda.schedule('3 days', 'runDangerTask', { name: "mid_week_rfc_notification", data: issue }); Which can get hooked up to a generic task runner inside Peril. |
So we can do "in one week" or whatever
The text was updated successfully, but these errors were encountered: