Back to APIs

Subscribe to webhooks and automate tasks in your code repositories.

Using our official GitHub integration

Easily subscribe to GitHub webhooks to trigger your jobs.

Create any tasks possible with the GitHub API.

Use io.runTask() and the official SDK or fetch.

GitHub integration docs

Example code using GitHub

Below are some working code examples of how you can use GitHub with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

1
import { TriggerClient } from "@trigger.dev/sdk";
2
import { Github, events } from "@trigger.dev/github";
3
import { Slack } from "@trigger.dev/slack";
4
5
const github = new Github({ id: "github" });
6
const slack = new Slack({ id: "slack" });
7
8
// This Job will run when a star is added or removed from the triggerdotdev/trigger.dev repo
9
client.defineJob({
10
id: "github-new-star-to-slack",
11
name: "GitHub: new star to slack",
12
version: "1.0.0",
13
trigger: github.triggers.repo({
14
event: events.onStar,
15
owner: "<your-org-name>",
16
repo: "<your-repo-name>",
17
}),
18
integrations: {
19
slack,
20
},
21
run: async (payload, io, ctx) => {
22
await io.slack.postMessage("post message", {
23
channel: process.env.SLACK_CHANNEL_ID!,
24
text: `New GitHub star from ${payload.sender.html_url}, ${payload.sender.name}. Your new GitHub star count is ${payload.repository.stargazers_count}.`,
25
});
26
},
27
});

Full-stack GitHub example projects