Skip to content

Commit 3c431f9

Browse files
BinHPdevclaude
andcommitted
Replace GitHub Actions with local Claude Code script
- Removed GitHub Actions workflow (no API key needed) - Added scripts/weekly-update.sh: local cron script using claude -p - Uses local Claude Code subscription instead of API billing - Supports --dry-run mode for testing - Added .gitignore for script logs Setup: crontab -e → 0 12 * * 5 cd /path/to/repo && ./scripts/weekly-update.sh Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dc4193a commit 3c431f9

3 files changed

Lines changed: 137 additions & 120 deletions

File tree

.github/workflows/weekly-update.yml

Lines changed: 0 additions & 120 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Update script logs
2+
scripts/*.log
3+
scripts/last-run-*.log

scripts/weekly-update.sh

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#!/bin/bash
2+
#
3+
# weekly-update.sh — 每周五中午自动更新 awesome-algorithm-auto-tools
4+
#
5+
# 使用本地 Claude Code(用你的订阅额度,不需要 API key)
6+
# 流程:搜索最新工具 → 更新文档 → 提交 → 推送 → 创建 PR
7+
#
8+
# 用法:
9+
# ./scripts/weekly-update.sh # 正常执行
10+
# ./scripts/weekly-update.sh --dry-run # 只搜索,不提交不推送
11+
#
12+
# 设置定时任务(二选一):
13+
# 方式 1: crontab -e 然后添加:
14+
# 0 12 * * 5 cd /Users/bin/Desktop/project/AfterPho/newRD/awesome-algorithm-auto-tools && ./scripts/weekly-update.sh >> scripts/update.log 2>&1
15+
#
16+
# 方式 2: 在 Claude Code 中运行:
17+
# /schedule 命令设置
18+
19+
set -euo pipefail
20+
21+
# ── 配置 ──────────────────────────────────────────────
22+
PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
23+
PROMPT_FILE="$PROJECT_DIR/.github/prompts/weekly-update.md"
24+
LOG_DIR="$PROJECT_DIR/scripts"
25+
DATE=$(date +%Y-%m-%d)
26+
BRANCH="auto-update/${DATE}"
27+
DRY_RUN=false
28+
29+
if [[ "${1:-}" == "--dry-run" ]]; then
30+
DRY_RUN=true
31+
echo "[$DATE] Dry-run mode: will search but not commit/push"
32+
fi
33+
34+
# ── 日志 ──────────────────────────────────────────────
35+
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"; }
36+
37+
# ── 前置检查 ──────────────────────────────────────────
38+
log "Starting weekly update..."
39+
cd "$PROJECT_DIR"
40+
41+
if ! command -v claude &>/dev/null; then
42+
log "ERROR: claude CLI not found. Install: npm i -g @anthropic-ai/claude-code"
43+
exit 1
44+
fi
45+
46+
if ! command -v gh &>/dev/null; then
47+
log "ERROR: gh CLI not found. Install: brew install gh"
48+
exit 1
49+
fi
50+
51+
# 确保在 main 分支且代码最新
52+
log "Syncing main branch..."
53+
git checkout main
54+
git pull origin main
55+
56+
# 创建更新分支
57+
log "Creating branch: $BRANCH"
58+
git checkout -b "$BRANCH"
59+
60+
# ── 执行 Claude Code 更新 ────────────────────────────
61+
log "Running Claude Code to search for new tools..."
62+
PROMPT=$(cat "$PROMPT_FILE")
63+
64+
claude -p "$PROMPT" \
65+
--max-turns 30 \
66+
--allowedTools "WebSearch,Read,Edit,Write,Glob,Grep,Bash(git diff*),Bash(git status*),Bash(wc *)" \
67+
2>&1 | tee "$LOG_DIR/last-run-${DATE}.log"
68+
69+
# ── 检查是否有变更 ───────────────────────────────────
70+
if git diff --quiet && git diff --cached --quiet; then
71+
log "No new tools found this week. Cleaning up."
72+
git checkout main
73+
git branch -D "$BRANCH"
74+
echo "$DATE: No new tools found." >> "$LOG_DIR/history.log"
75+
exit 0
76+
fi
77+
78+
log "Changes detected:"
79+
git diff --stat
80+
81+
if $DRY_RUN; then
82+
log "Dry-run complete. Discarding changes."
83+
git checkout -- .
84+
git checkout main
85+
git branch -D "$BRANCH"
86+
exit 0
87+
fi
88+
89+
# ── 提交 + 推送 + 创建 PR ────────────────────────────
90+
log "Committing changes..."
91+
git add README.md "算法自动化训练.md"
92+
git commit -m "$(cat <<EOF
93+
Auto-update: add new tools (${DATE})
94+
95+
Weekly automated scan for new algorithm automation tools.
96+
97+
Co-Authored-By: Claude <noreply@anthropic.com>
98+
EOF
99+
)"
100+
101+
log "Pushing to origin..."
102+
git push -u origin "$BRANCH"
103+
104+
log "Creating PR..."
105+
PR_URL=$(gh pr create \
106+
--title "Weekly update: new tools (${DATE})" \
107+
--body "$(cat <<'PREOF'
108+
## Summary
109+
110+
Automated weekly scan for new algorithm automation tools.
111+
112+
Generated by local Claude Code via `scripts/weekly-update.sh`.
113+
114+
## Review Checklist
115+
116+
- [ ] New entries are accurate and links work
117+
- [ ] Table formatting is correct in README.md
118+
- [ ] Chinese descriptions are appropriate
119+
- [ ] No existing entries were removed
120+
121+
---
122+
🤖 Auto-generated by weekly-update.sh + Claude Code
123+
PREOF
124+
)" \
125+
--base main \
126+
--head "$BRANCH")
127+
128+
log "PR created: $PR_URL"
129+
echo "$DATE: PR created - $PR_URL" >> "$LOG_DIR/history.log"
130+
131+
# 回到 main 分支
132+
git checkout main
133+
134+
log "Done!"

0 commit comments

Comments
 (0)