Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(ci): add /claim command to auto-assign issues

t8y20b8a213fc960
diff --git a/.github/scripts/issue-claim.mjs b/.github/scripts/issue-claim.mjs
new file mode 100644
index 0000000000..7e8b9ad01a
--- /dev/null
+++ b/.github/scripts/issue-claim.mjs
@@ -0,0 +1,59 @@
+#!/usr/bin/env node
+import { execFile } from "node:child_process";
+import { promisify } from "node:util";
+
+const execFileAsync = promisify(execFile);
+const issueNumber = process.env.ISSUE_NUMBER;
+const commentBody = process.env.COMMENT_BODY || "";
+const commentUser = process.env.COMMENT_USER || "";
+const commentUserType = process.env.COMMENT_USER_TYPE || "";
+
+// Only handle /claim as a standalone word
+if (!/(?:^|\s)\/claim(?:\s|$)/.test(commentBody)) {
+ process.exit(0);
+}
+
+// Don't let bots claim
+if (commentUserType === "Bot") {
+ console.log("Commenter is a bot, skipping");
+ process.exit(0);
+}
+
+console.log(`/claim from @${commentUser} on #${issueNumber}`);
+
+async function gh(args) {
+ const { stdout } = await execFileAsync("gh", args, { maxBuffer: 1024 * 1024 });
+ return stdout.trim();
+}
+
+async function ghJson(args) {
+ const out = await gh(args);
+ return JSON.parse(out);
+}
+
+// Check current assignees
+const assignees = await ghJson([
+ "issue", "view", issueNumber,
+ "--json", "assignees",
+ "-q", ".assignees",
+]);
+
+if (assignees.length > 0) {
+ const names = assignees.map((a) => `@${a.login}`).join(", ");
+ await gh([
+ "issue", "comment", issueNumber,
+ "--body", `❌ @${commentUser} 这个 issue 已经有人认领了:${names}`,
+ ]);
+ process.exit(0);
+}
+
+// Assign
+await gh(["issue", "edit", issueNumber, "--add-assignee", commentUser]);
+
+// Confirm
+await gh([
+ "issue", "comment", issueNumber,
+ "--body", `✅ @${commentUser} 已认领 #${issueNumber},开始处理吧!`,
+]);
+
+console.log(`Assigned @${commentUser} to #${issueNumber}`);
diff --git a/.github/workflows/issue-claim.yml b/.github/workflows/issue-claim.yml
new file mode 100644
index 0000000000..11c0f02952
--- /dev/null
+++ b/.github/workflows/issue-claim.yml
@@ -0,0 +1,26 @@
+name: Issue Claim
+
+on:
+ issue_comment:
+ types: [created]
+
+permissions:
+ contents: read
+ issues: write
+
+jobs:
+ claim:
+ runs-on: ubuntu-latest
+ if: ${{ !github.event.issue.pull_request }}
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Handle /claim command
+ run: node .github/scripts/issue-claim.mjs
+ env:
+ ISSUE_NUMBER: ${{ github.event.issue.number }}
+ COMMENT_BODY: ${{ github.event.comment.body }}
+ COMMENT_USER: ${{ github.event.comment.user.login }}
+ COMMENT_USER_TYPE: ${{ github.event.comment.user.type }}