When a GitHub repo is starred, post information about the user to Slack.
Integrations
Help and guides
Get started
Run this command in your terminal to create a new project using this template.
This template contains a GitHub newStarEvent Trigger that will run whenever the specified repository gets a new ⭐️:
import { Trigger } from "@trigger.dev/sdk";
import * as github from "@trigger.dev/github";
import * as slack from "@trigger.dev/slack";
// Change "triggerdotdev/github-stars-to-slack" to the repo you want to track e.g. "yourorg/yourrepo"
const repo =
process.env.GITHUB_REPOSITORY ?? "triggerdotdev/github-stars-to-slack";
new Trigger({
// Give your Trigger a stable ID
id: "github-stars-to-slack",
name: "GitHub Stars to Slack",
// This will register a webhook with the repo
// and trigger whenever the repo gets a new star
on: github.events.newStarEvent({
repo,
}),
// The run function will get called once per "new star" event
// See https://docs.trigger.dev/integrations/apis/github/events/new-star
run: async (event) => {
// Posts a new message to the "github-stars" slack channel.
// See https://docs.trigger.dev/integrations/apis/slack/actions/post-message
await slack.postMessage("⭐️", {
channelName: "github-stars",
text: `New GitHub star from \n<${event.sender.html_url}|${event.sender.login}>. You now have ${event.repository.stargazers_count} stars!`,
});
},
}).listen();
repo
parameter to point to a GitHub repository you manage by setting the GITHUB_REPOSITORY
environment variable.