1
import { TriggerClient } from "@trigger.dev/sdk";
2
import { Github, events } from "@trigger.dev/github";
3
import { Linear } from "@trigger.dev/linear";
4
import { Slack } from "@trigger.dev/slack";
5
const linear = new Linear({
7
apiKey: process.env.LINEAR_API_KEY!,
9
const slack = new Slack({ id: "slack" });
11
const github = new Github({ id: "github" });
14
id: "linear-create-issue-on-github-pr",
15
name: "Create a Linear issue when a pull request is opened on a GitHub repo",
17
trigger: github.triggers.repo({
18
event: events.onPullRequest,
19
owner: "<your-org-name>",
20
repo: "<your-repo-name>",
27
run: async (payload, io, ctx) => {
28
const pullRequestTitle = payload.pull_request.title;
29
const pullRequestURL = payload.pull_request.issue_url;
30
const pullRequestAuthorURL = payload.sender.html_url;
31
const pullRequestDescription = payload.pull_request.body;
33
const issue = await io.linear.createIssue("create issue", {
34
title: pullRequestTitle,
35
description: pullRequestDescription,
37
teamId: "<your-team-uuid>",
40
await io.slack.postMessage("post message", {
42
channel: process.env.SLACK_CHANNEL_ID!,
43
text: `⚡️ New pull request, "${pullRequestTitle}", ${pullRequestURL},
44
\n created by 👨💻 "${pullRequestAuthorURL}"
45
\n New issue has been created in Linear: ${issue?.url}.`,