Skip to content

Commit d993714

Browse files
Update workflow to create log issue on trigger
- Add new job 'create-log-issue' that runs before the main LLM bot job - Issue title: [工作流]<LLM_TASK content> - Issue body includes task description, context JSON, and workflow run link - Uses GitHub Actions built-in token (GITHUB_TOKEN) for issue creation - Issue created before agent's token environment variables are set - Main job now depends on create-log-issue job completion Co-Authored-By: Claude (mimo-v2-flash) <noreply@anthropic.com>
1 parent 016fcd4 commit d993714

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

.github/workflows/llm-bot-runner.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,69 @@ on:
1313
type: string
1414

1515
jobs:
16+
create-log-issue:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
issues: write
20+
steps:
21+
- name: Create log issue
22+
uses: actions/github-script@v7
23+
with:
24+
script: |
25+
const task = `${{ inputs.task }}`;
26+
const contextStr = `${{ inputs.context }}`;
27+
28+
let context;
29+
try {
30+
context = JSON.parse(contextStr);
31+
} catch (e) {
32+
context = { error: "Failed to parse context", raw: contextStr.substring(0, 1000) };
33+
}
34+
35+
const issueTitle = `[工作流]${task}`;
36+
const issueBody = `**Triggered by:** GitHub Actions workflow_dispatch
37+
38+
**Task:**
39+
\`\`\`
40+
${task}
41+
\`\`\`
42+
43+
**Context:**
44+
\`\`\`json
45+
${JSON.stringify(context, null, 2)}
46+
\`\`\`
47+
48+
**Workflow Run:** ${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}
49+
`;
50+
51+
// Use the repo from context if available, otherwise use the current repo
52+
let owner, repo;
53+
if (context.repo) {
54+
const parts = context.repo.split('/');
55+
owner = parts[0];
56+
repo = parts[1];
57+
} else {
58+
owner = process.env.GITHUB_REPOSITORY_OWNER;
59+
repo = process.env.GITHUB_REPOSITORY.split('/')[1];
60+
}
61+
62+
const { data: issue } = await github.rest.issues.create({
63+
owner: owner,
64+
repo: repo,
65+
title: issueTitle,
66+
body: issueBody
67+
});
68+
69+
core.exportValue('issue_number', issue.number);
70+
console.log(`Created issue #${issue.number} in ${owner}/${repo}`);
71+
1672
run-llm-bot:
73+
needs: create-log-issue
1774
runs-on: ubuntu-latest
1875
env:
1976
LLM_TASK: ${{ inputs.task }}
2077
LLM_CONTEXT: ${{ inputs.context }}
21-
# GitHub身份令牌(4个名称都设置)
78+
# GitHub身份令牌(4个名称都设置)- 使用GitHub Actions内置的token(在环境变量赋值前创建issue已完成)
2279
GITHUB_TOKEN: ${{ secrets.WEINAR_API_KEY }}
2380
GH_TOKEN: ${{ secrets.WEINAR_API_KEY }}
2481
GITHUBTOKEN: ${{ secrets.WEINAR_API_KEY }}

0 commit comments

Comments
 (0)