Skip to content

Commit 992e990

Browse files
feat(workflow): 在触发时创建issue以记录日志
- 在workflow启动时创建日志issue,标题格式为"[工作流]<任务内容>" - 使用GitHub Actions内置的GITHUB_TOKEN创建issue,避免与agent token冲突 - issue body包含完整的context JSON内容 - 创建时机在agent token环境变量赋值之前
1 parent be53d57 commit 992e990

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
env:
1919
LLM_TASK: ${{ inputs.task }}
2020
LLM_CONTEXT: ${{ inputs.context }}
21-
# GitHub身份令牌(4个名称都设置)
21+
# GitHub身份令牌(4个名称都设置)- 使用agent的token
2222
GITHUB_TOKEN: ${{ secrets.WEINAR_API_KEY }}
2323
GH_TOKEN: ${{ secrets.WEINAR_API_KEY }}
2424
GITHUBTOKEN: ${{ secrets.WEINAR_API_KEY }}
@@ -42,11 +42,45 @@ jobs:
4242
pull-requests: write
4343
issues: write
4444
discussions: write
45+
permissions:
46+
contents: write
47+
pull-requests: write
48+
issues: write
49+
discussions: write
4550
defaults:
4651
run:
4752
working-directory: /home/runner/work
4853
steps:
4954

55+
- name: Create log issue
56+
run: |
57+
# 使用GitHub Actions内置的GITHUB_TOKEN创建issue(在agent token赋值前)
58+
ISSUE_TITLE="[工作流]${{ inputs.task }}"
59+
ISSUE_BODY="${{ inputs.context }}"
60+
61+
echo "创建日志issue..."
62+
echo "标题: $ISSUE_TITLE"
63+
echo "Body长度: ${#ISSUE_BODY} 字符"
64+
65+
# 创建issue并获取issue number
66+
ISSUE_RESPONSE=$(curl -s -X POST \
67+
-H "Authorization: token $GITHUB_ACTIONS_TOKEN" \
68+
-H "Accept: application/vnd.github.v3+json" \
69+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues" \
70+
-d "{\"title\":\"$ISSUE_TITLE\",\"body\":\"$ISSUE_BODY\"}")
71+
72+
ISSUE_NUMBER=$(echo "$ISSUE_RESPONSE" | grep -o '"number":[[:space:]]*[0-9]*' | cut -d':' -f2 | tr -d ' ')
73+
74+
if [ -n "$ISSUE_NUMBER" ]; then
75+
echo "日志issue已创建,编号: $ISSUE_NUMBER"
76+
echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV
77+
else
78+
echo "警告: 无法创建issue,继续执行工作流"
79+
echo "Issue创建响应: $ISSUE_RESPONSE"
80+
fi
81+
env:
82+
GITHUB_ACTIONS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
5084
- name: Install Claude CLI
5185
run: |
5286
curl -fsSL https://claude.ai/install.sh | bash

0 commit comments

Comments
 (0)