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";
6
const linear = new Linear({
8
apiKey: process.env.LINEAR_API_KEY!,
10
const slack = new Slack({ id: "slack" });
12
const github = new Github({ id: "github" });
15
id: "linear-create-issue-on-github-pr",
16
name: "Create a Linear issue when a pull request is opened on a GitHub repo",
18
trigger: github.triggers.repo({
19
event: events.onPullRequest,
20
owner: "<your-org-name>",
21
repo: "<your-repo-name>",
28
run: async (payload, io, ctx) => {
29
const pullRequestTitle = payload.pull_request.title;
30
const pullRequestURL = payload.pull_request.issue_url;
31
const pullRequestAuthorURL = payload.sender.html_url;
32
const pullRequestDescription = payload.pull_request.body;
34
const issue = await io.linear.createIssue("create issue", {
35
title: pullRequestTitle,
36
description: pullRequestDescription,
38
teamId: "<your-team-uuid>",
41
await io.slack.postMessage("post message", {
43
channel: process.env.SLACK_CHANNEL_ID!,
44
text: `⚡️ New pull request, "${pullRequestTitle}", ${pullRequestURL},
45
\n created by 👨💻 "${pullRequestAuthorURL}"
46
\n New issue has been created in Linear: ${issue?.url}.`,