Skip to content

Daily Change Summary #36

Daily Change Summary

Daily Change Summary #36

Workflow file for this run

name: Daily Change Summary
on:
schedule:
- cron: '0 16 * * *' # UTC 16:00 = Beijing 0:00
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
daily-summary:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
- name: Check for changes
id: check
run: |
# Ensure HEAD is at the true latest main, not the stale schedule SHA
git checkout main
git log --oneline -1
SINCE=$(date -u -d "24 hours ago" +%Y-%m-%dT%H:%M:%S)
echo "SINCE=$SINCE"
COUNT=$(git log --since="$SINCE" --oneline --no-merges | wc -l)
echo "commit_count=$COUNT" >> "$GITHUB_OUTPUT"
echo "since=$SINCE" >> "$GITHUB_OUTPUT"
if [ "$COUNT" -eq "0" ]; then
echo "No commits in the last 24 hours, skipping."
else
echo "Found $COUNT commits since $SINCE"
fi
- name: Setup Node.js
if: steps.check.outputs.commit_count != '0'
uses: actions/setup-node@v6
with:
node-version: '25'
- name: Install Copilot CLI
if: steps.check.outputs.commit_count != '0'
run: npm install -g @github/copilot
- name: Generate summary
if: steps.check.outputs.commit_count != '0'
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_PAT }}
run: |
SINCE="${{ steps.check.outputs.since }}"
GIT_LOG=$(git log main --since="$SINCE" --pretty=format:"%h %s (%an, %ar)" --no-merges)
OLDEST=$(git log main --since="$SINCE" --format="%H" --no-merges | tail -1)
DIFF_STAT=$(git diff --stat "${OLDEST}^..main" 2>/dev/null || echo "N/A")
PROMPT=$(cat <<'PROMPT_EOF'
你是一个代码仓库的每日变更总结助手。请根据以下 git 信息,用中文生成一份结构化的每日变更总结报告。
请按以下格式输出:
1. **概览**:一句话总结今天的主要变更
2. **详细变更**:按功能模块分组列出变更内容
3. **影响范围**:列出受影响的主要模块/文件
4. **备注**:任何值得关注的变更(如破坏性变更、新依赖等)
PROMPT_EOF
)
copilot -p "${PROMPT}
## Git Commit 日志:
${GIT_LOG}
## 文件变更统计:
${DIFF_STAT}" > /tmp/summary.md
- name: Create Issue
if: steps.check.outputs.commit_count != '0'
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TODAY=$(date +%Y-%m-%d)
COMMITS="${{ steps.check.outputs.commit_count }}"
SUMMARY=$(cat /tmp/summary.md)
BODY="$(printf '> 自动生成的每日变更总结 | %s 个 commit\n\n%s\n\n---\n*由 GitHub Copilot + Actions 自动生成*' "$COMMITS" "$SUMMARY")"
gh issue create \
--repo "${{ github.repository }}" \
--title "📋 每日变更总结 - ${TODAY}" \
--body "$BODY" \
--label "daily-summary"
- name: Send to Feishu
if: steps.check.outputs.commit_count != '0'
env:
FEISHU_WEBHOOK_URLS: ${{ secrets.FEISHU_WEBHOOK_URL }}
run: |
TODAY=$(date +%Y-%m-%d)
COMMITS="${{ steps.check.outputs.commit_count }}"
SUMMARY=$(cat /tmp/summary.md)
REPO_URL="https://github.com/${{ github.repository }}"
PAYLOAD=$(jq -n \
--arg title "📋 InnoClaw 每日变更总结 - ${TODAY}" \
--arg commits "${COMMITS} 个 commit" \
--arg summary "$SUMMARY" \
--arg repo_url "$REPO_URL" \
'{
"msg_type": "interactive",
"card": {
"header": {
"title": { "tag": "plain_text", "content": $title },
"template": "blue"
},
"elements": [
{
"tag": "div",
"text": { "tag": "lark_md", "content": $commits }
},
{ "tag": "hr" },
{
"tag": "div",
"text": { "tag": "lark_md", "content": $summary }
},
{ "tag": "hr" },
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": { "tag": "plain_text", "content": "查看仓库" },
"url": $repo_url,
"type": "primary"
}
]
}
]
}
}')
# Support multiple webhook URLs separated by commas
IFS=',' read -ra URLS <<< "$FEISHU_WEBHOOK_URLS"
for URL in "${URLS[@]}"; do
URL=$(echo "$URL" | xargs) # trim whitespace
if [ -n "$URL" ]; then
echo "Sending to webhook: ${URL:0:60}..."
curl -s -X POST "$URL" \
-H "Content-Type: application/json" \
-d "$PAYLOAD"
echo ""
fi
done