Skip to content

Commit 9c486a4

Browse files
Add create-diff-issue job to update-system-prompt workflow
- Fetch old SYSTEM_PROMPT variable value before update - Save old value to /tmp/old_value.txt for use in next job - Add new create-diff-issue job that: - Reads old and new values - Creates diff between them - Creates issue with workflow and documentation labels - Issue title: [工作流] 提示词更新 <run_id> - Issue body includes workflow run link and diff Co-Authored-By: Claude (mimo-v2-flash) <noreply@anthropic.com>
0 parents  commit 9c486a4

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Update System Prompt
2+
3+
on:
4+
push:
5+
paths:
6+
- 'system_prompt.md'
7+
workflow_dispatch:
8+
9+
jobs:
10+
update:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
actions: write
14+
contents: read
15+
env:
16+
GH_TOKEN: ${{ secrets.REPOSITORY_VARIABLE_API_KEY }}
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 1
22+
23+
- name: Update SYSTEM_PROMPT variable
24+
id: update
25+
run: |
26+
echo "正在更新 SYSTEM_PROMPT 变量..."
27+
28+
# 检查 system_prompt.md 文件是否存在
29+
if [ ! -f "system_prompt.md" ]; then
30+
echo "错误: system_prompt.md 文件不存在"
31+
exit 1
32+
fi
33+
34+
# 读取 system_prompt.md 内容
35+
SYSTEM_PROMPT_CONTENT=$(cat system_prompt.md)
36+
37+
# 获取旧变量值
38+
OLD_VALUE=$(gh api /repos/${{ github.repository }}/actions/variables/SYSTEM_PROMPT --jq '.value' 2>/dev/null || echo "")
39+
40+
# 更新 GitHub Actions 变量
41+
gh api --method PATCH \
42+
/repos/${{ github.repository }}/actions/variables/SYSTEM_PROMPT \
43+
-f name=SYSTEM_PROMPT \
44+
-f value="$SYSTEM_PROMPT_CONTENT"
45+
46+
echo "✓ SYSTEM_PROMPT 变量已更新"
47+
echo "文件大小: $(wc -c < system_prompt.md) 字符"
48+
49+
# 保存旧值到文件供下一步使用
50+
echo "$OLD_VALUE" > /tmp/old_value.txt
51+
52+
create-diff-issue:
53+
needs: update
54+
runs-on: ubuntu-latest
55+
permissions:
56+
issues: write
57+
contents: read
58+
env:
59+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
steps:
61+
- name: Create diff issue
62+
run: |
63+
# 读取旧值
64+
OLD_VALUE=$(cat /tmp/old_value.txt)
65+
# 读取新值
66+
NEW_VALUE=$(cat system_prompt.md)
67+
68+
# 构建 diff 内容
69+
DIFF_CONTENT=$(diff -u <(echo "$OLD_VALUE") <(echo "$NEW_VALUE") 2>/dev/null || echo "No diff available")
70+
71+
# 构建 issue 内容
72+
ISSUE_BODY="[工作流运行 #${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
73+
74+
\`\`\`diff
75+
${DIFF_CONTENT}
76+
\`\`\`"
77+
78+
# 创建 issue
79+
gh issue create \
80+
--title "[工作流] 提示词更新 ${{ github.run_id }}" \
81+
--body "$ISSUE_BODY" \
82+
--label workflow \
83+
--label documentation

0 commit comments

Comments
 (0)