Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(github): comment the task link on issues created from Kaneo

Andrejdc31480a1e22
diff --git a/apps/api/src/plugins/github/events/task-created.ts b/apps/api/src/plugins/github/events/task-created.ts
index 0fb3188b3..b4e8a3631 100644
--- a/apps/api/src/plugins/github/events/task-created.ts
+++ b/apps/api/src/plugins/github/events/task-created.ts
@@ -1,3 +1,6 @@
+import { eq } from "drizzle-orm";
+import db from "../../../database";
+import { projectTable } from "../../../database/schema";
import type { PluginContext, TaskCreatedEvent } from "../../types";
import type { GitHubConfig } from "../config";
import {
@@ -73,6 +76,26 @@ export async function handleTaskCreated(
createdFrom: "kaneo",
},
});
+
+ if (config.commentTaskLinkOnGitHubIssue !== false) {
+ const project = await db.query.projectTable.findFirst({
+ where: eq(projectTable.id, event.projectId),
+ });
+
+ if (project) {
+ const clientUrl =
+ process.env.KANEO_CLIENT_URL || "http://localhost:5173";
+ const taskUrl = `${clientUrl}/dashboard/workspace/${project.workspaceId}/project/${event.projectId}/task/${event.taskId}`;
+ const taskIdentifier = `${project.slug.toUpperCase()}-${event.number}`;
+
+ await octokit.rest.issues.createComment({
+ owner: repositoryOwner,
+ repo: repositoryName,
+ issue_number: createdIssue.data.number,
+ body: `[${taskIdentifier}](${taskUrl})`,
+ });
+ }
+ }
} catch (error) {
console.error("Failed to create GitHub issue:", error);
}