mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-09 05:19:32 +08:00
116 lines
4.0 KiB
YAML
116 lines
4.0 KiB
YAML
name: Auto response
|
||
|
||
on:
|
||
issues:
|
||
types: [opened, edited, labeled]
|
||
pull_request_target:
|
||
types: [labeled]
|
||
|
||
permissions: {}
|
||
|
||
jobs:
|
||
auto-response:
|
||
permissions:
|
||
issues: write
|
||
pull-requests: write
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1
|
||
id: app-token
|
||
with:
|
||
app-id: "2729701"
|
||
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
||
- name: Handle labeled items
|
||
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
||
with:
|
||
github-token: ${{ steps.app-token.outputs.token }}
|
||
script: |
|
||
// Labels prefixed with "r:" are auto-response triggers.
|
||
const rules = [
|
||
{
|
||
label: "r: skill",
|
||
close: true,
|
||
message:
|
||
"Thanks for the contribution! New skills should be published to [Clawhub](https://clawhub.ai) for everyone to use. We’re keeping the core lean on skills, so I’m closing this out.",
|
||
},
|
||
{
|
||
label: "r: support",
|
||
close: true,
|
||
message:
|
||
"Please use [our support server](https://discord.gg/clawd) and ask in #help or #users-helping-users to resolve this, or follow the stuck FAQ at https://docs.openclaw.ai/help/faq#im-stuck-whats-the-fastest-way-to-get-unstuck.",
|
||
},
|
||
{
|
||
label: "r: third-party-extension",
|
||
close: true,
|
||
message:
|
||
"This would be better made as a third-party extension with our SDK that you maintain yourself. Docs: https://docs.openclaw.ai/plugin.",
|
||
},
|
||
{
|
||
label: "r: moltbook",
|
||
close: true,
|
||
lock: true,
|
||
lockReason: "off-topic",
|
||
message:
|
||
"OpenClaw is not affiliated with Moltbook, and issues related to Moltbook should not be submitted here.",
|
||
},
|
||
];
|
||
|
||
const issue = context.payload.issue;
|
||
if (issue) {
|
||
const title = issue.title ?? "";
|
||
const body = issue.body ?? "";
|
||
const haystack = `${title}\n${body}`.toLowerCase();
|
||
const hasLabel = (issue.labels ?? []).some((label) =>
|
||
typeof label === "string" ? label === "r: moltbook" : label?.name === "r: moltbook",
|
||
);
|
||
if (haystack.includes("moltbook") && !hasLabel) {
|
||
await github.rest.issues.addLabels({
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
issue_number: issue.number,
|
||
labels: ["r: moltbook"],
|
||
});
|
||
return;
|
||
}
|
||
}
|
||
|
||
const labelName = context.payload.label?.name;
|
||
if (!labelName) {
|
||
return;
|
||
}
|
||
|
||
const rule = rules.find((item) => item.label === labelName);
|
||
if (!rule) {
|
||
return;
|
||
}
|
||
|
||
const issueNumber = context.payload.issue?.number ?? context.payload.pull_request?.number;
|
||
if (!issueNumber) {
|
||
return;
|
||
}
|
||
|
||
await github.rest.issues.createComment({
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
issue_number: issueNumber,
|
||
body: rule.message,
|
||
});
|
||
|
||
if (rule.close) {
|
||
await github.rest.issues.update({
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
issue_number: issueNumber,
|
||
state: "closed",
|
||
});
|
||
}
|
||
|
||
if (rule.lock) {
|
||
await github.rest.issues.lock({
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
issue_number: issueNumber,
|
||
lock_reason: rule.lockReason ?? "resolved",
|
||
});
|
||
}
|