121 lines
2.4 KiB
Plaintext
121 lines
2.4 KiB
Plaintext
---
|
|
title: "GitHub"
|
|
sidebarTitle: "GitHub"
|
|
description: "Here are some example workflows you could create using the GitHub integration."
|
|
---
|
|
|
|
You can explore all the supported GitHub functions [here](/integrations/apis/github/events/push).
|
|
|
|
### Example workflows:
|
|
|
|
## When a GitHub repo is starred, post information about the user to Slack
|
|
|
|
Integrations required: GitHub, Slack
|
|
|
|
Packages required:
|
|
|
|
<Tabs>
|
|
<Tab title="npm">
|
|
|
|
```bash
|
|
npm install @trigger.dev/github @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
<Tab title="pnpm">
|
|
|
|
```bash
|
|
pnpm add @trigger.dev/github @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
<Tab title="yarn">
|
|
|
|
```bash
|
|
yarn add @trigger.dev/github @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
Workflow code:
|
|
|
|
```ts
|
|
import { Trigger } from "@trigger.dev/sdk";
|
|
import * as github from "@trigger.dev/github";
|
|
import * as slack from "@trigger.dev/slack";
|
|
|
|
new Trigger({
|
|
id: "new-github-star-to-slack",
|
|
name: "New GitHub Star: triggerdotdev/trigger.dev",
|
|
apiKey: "<my_api_key>",
|
|
on: github.events.newStarEvent({
|
|
repo: "triggerdotdev/trigger.dev",
|
|
}),
|
|
run: async (event) => {
|
|
await slack.postMessage("github-stars", {
|
|
channelName: "github-stars",
|
|
text: `New GitHub star from \n<${event.sender.html_url}|${event.sender.login}>`,
|
|
});
|
|
},
|
|
}).listen();
|
|
```
|
|
|
|
## When a GitHub issue is created or modified, post to Slack
|
|
|
|
Integrations required: GitHub, Slack
|
|
|
|
Packages required:
|
|
|
|
<Tabs>
|
|
<Tab title="npm">
|
|
|
|
```bash
|
|
npm install @trigger.dev/github @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
<Tab title="pnpm">
|
|
|
|
```bash
|
|
pnpm add @trigger.dev/github @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
<Tab title="yarn">
|
|
|
|
```bash
|
|
yarn add @trigger.dev/github @trigger.dev/slack
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
Workflow code:
|
|
|
|
```ts
|
|
import { Trigger } from "@trigger.dev/sdk";
|
|
import * as github from "@trigger.dev/github";
|
|
import * as slack from "@trigger.dev/slack";
|
|
|
|
new Trigger({
|
|
id: "my-workflow-1",
|
|
name: "Posts to Slack when GitHub Issue created or modified",
|
|
apiKey: "<my_api_key>",
|
|
on: github.events.issueEvent({
|
|
repo: "my-github-org/my-github-repo",
|
|
}),
|
|
|
|
run: async (event, ctx) => {
|
|
const response = await slack.postMessage("send-to-slack", {
|
|
channelName: "my-slack-channel-name",
|
|
text: `A new issue has been created or modified. ${event.action}`,
|
|
});
|
|
|
|
return response.message;
|
|
},
|
|
}).listen();
|
|
```
|
|
|
|
You can explore all the supported GitHub functions [here](/integrations/apis/github/events/push).
|