@@ -12,78 +12,32 @@ jobs:
1212 permissions :
1313 actions : write
1414 contents : read
15- outputs :
16- oldvalue : ${{ steps.save-old.outputs.oldvalue }}
15+ env :
16+ GH_TOKEN : ${{ secrets.REPOSITORY_VARIABLE_API_KEY }}
1717 steps :
1818 - name : Checkout repository
1919 uses : actions/checkout@v4
2020 with :
2121 fetch-depth : 1
2222
2323 - name : Update SYSTEM_PROMPT variable
24- id : save-old
25- env :
26- GH_TOKEN : ${{ secrets.REPOSITORYVARIABLEAPIKEY }}
2724 run : |
2825 echo "正在更新 SYSTEM_PROMPT 变量..."
2926
27+ # 检查 system_prompt.md 文件是否存在
3028 if [ ! -f "system_prompt.md" ]; then
3129 echo "错误: system_prompt.md 文件不存在"
3230 exit 1
3331 fi
3432
35- SYSTEMPROMPTCONTENT=$(cat system_prompt.md)
36-
37- # 获取旧变量值并存入 outputs (修正变量名 REPO 为 github.repository)
38- OLDVALUE=$(gh api /repos/${{ github.repository }}/actions/variables/SYSTEM_PROMPT --jq '.value' 2>/dev/null || echo "")
39-
40- echo "oldvalue<<EOF" >> $GITHUB_OUTPUT
41- echo "$OLDVALUE" >> $GITHUB_OUTPUT
42- echo "EOF" >> $GITHUB_OUTPUT
33+ # 读取 system_prompt.md 内容
34+ SYSTEM_PROMPT_CONTENT=$(cat system_prompt.md)
4335
4436 # 更新 GitHub Actions 变量
4537 gh api --method PATCH \
4638 /repos/${{ github.repository }}/actions/variables/SYSTEM_PROMPT \
4739 -f name=SYSTEM_PROMPT \
48- -f value="$SYSTEMPROMPTCONTENT "
40+ -f value="$SYSTEM_PROMPT_CONTENT "
4941
5042 echo "✓ SYSTEM_PROMPT 变量已更新"
51- echo "文件大小: $(wc -c < system_prompt.md) 字符"
52-
53- create-diff-issue :
54- needs : update
55- runs-on : ubuntu-latest
56- permissions :
57- issues : write
58- contents : read
59- env :
60- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61- steps :
62- - name : Checkout repository
63- uses : actions/checkout@v4
64- with :
65- fetch-depth : 1
66-
67- - name : Create diff issue
68- run : |
69- # 读取旧值(来自 update job)
70- OLDVALUE='${{ needs.update.outputs.oldvalue }}'
71- # 读取新值 (修正文件名 system_prompt.md)
72- NEWVALUE=$(cat system_prompt.md)
73-
74- # 构建 diff 内容
75- DIFFCONTENT=$(diff -u <(echo "$OLDVALUE") <(echo "$NEWVALUE") 2>/dev/null || echo "No diff available")
76-
77- # 严格按照你要求的结构构建 Issue Body,使用文件避免转义问题
78- echo "工作流运行 #${{ github.run_id }}" > issue_body.txt
79- echo "" >> issue_body.txt
80- echo "\`\`\`diff" >> issue_body.txt
81- echo "$DIFFCONTENT" >> issue_body.txt
82- echo "\`\`\`" >> issue_body.txt
83-
84- # 创建 issue
85- gh issue create \
86- --title "[工作流] 提示词更新 ${{ github.run_id }}" \
87- --body-file issue_body.txt \
88- --label workflow \
89- --label documentation
43+ echo "文件大小: $(wc -c < system_prompt.md) 字符"
0 commit comments