Skip to content

Commit 7c85ad3

Browse files
committed
Switch to self-hosted runner (ClaudeNotice pattern)
- runs-on: self-hosted — runs on local Mac, uses Claude subscription - Auto-commit + push to main directly, no PR review needed - caffeinate prevents Mac sleep during execution - Added setup_runner.sh for runner registration - Removed old local cron script
1 parent 3c431f9 commit 7c85ad3

3 files changed

Lines changed: 141 additions & 134 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Weekly Content Update
2+
3+
on:
4+
schedule:
5+
# 每周五中午 12:00 北京时间 (UTC+8) = 04:00 UTC
6+
- cron: '0 4 * * 5'
7+
workflow_dispatch:
8+
# 支持手动触发
9+
10+
jobs:
11+
update:
12+
# 在本地 Mac 执行(复用 ClaudeNotice 的 self-hosted runner)
13+
runs-on: self-hosted
14+
permissions:
15+
contents: write
16+
17+
timeout-minutes: 30
18+
steps:
19+
- name: 检出代码
20+
uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: 检查 Claude CLI
25+
run: |
26+
command -v claude || { echo "❌ claude CLI not found"; exit 1; }
27+
echo "✅ Claude CLI ready"
28+
29+
- name: 运行 Claude Code 搜索更新
30+
timeout-minutes: 20
31+
run: |
32+
# 防止 Mac 休眠
33+
caffeinate -s -w $$ &
34+
35+
PROMPT=$(cat .github/prompts/weekly-update.md)
36+
echo "🔍 开始搜索最新算法自动化工具..."
37+
38+
claude -p "$PROMPT" \
39+
--max-turns 30 \
40+
--allowedTools "WebSearch,Read,Edit,Write,Glob,Grep,Bash(git diff*),Bash(git status*),Bash(wc *)" \
41+
2>&1 | tee /tmp/awesome-algo-update.log
42+
43+
echo "✅ Claude 搜索完成"
44+
45+
- name: 提交并推送
46+
run: |
47+
git config user.name "AlgoTools Bot"
48+
git config user.email "bot@awesome-algo-tools.local"
49+
50+
# 暂存主文件
51+
git add README.md "算法自动化训练.md"
52+
53+
# 检查是否有实际变更
54+
if git diff --cached --quiet; then
55+
echo "📭 本周无新工具,跳过提交"
56+
exit 0
57+
fi
58+
59+
echo "📝 检测到变更:"
60+
git diff --cached --stat
61+
62+
git commit -m "chore: weekly update $(date +%Y-%m-%d)
63+
64+
Automated scan for new algorithm automation tools.
65+
66+
Co-Authored-By: Claude <noreply@anthropic.com>"
67+
68+
git push origin main
69+
echo "✅ 已推送到 main"

scripts/setup_runner.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
# ============================================================
3+
# awesome-algorithm-auto-tools — 自托管 Runner 安装
4+
#
5+
# 如果你已经在 ClaudeNotice 项目配置过 self-hosted runner,
6+
# 有两种方式复用:
7+
#
8+
# 方式 A(推荐):组织级 Runner
9+
# 将已有 runner 改为组织级,所有仓库共享
10+
# GitHub → Settings → Actions → Runners → 移到 Organization
11+
#
12+
# 方式 B:为本仓库单独注册一个 Runner
13+
# 运行本脚本:./scripts/setup_runner.sh
14+
#
15+
# 使用前:
16+
# 1. 打开 https://github.com/BinHPdev/awesome-algorithm-auto-tools
17+
# 2. Settings → Actions → Runners → New self-hosted runner
18+
# 3. 复制 token,粘贴到下面
19+
# ============================================================
20+
21+
set -e
22+
23+
GITHUB_REPO="https://github.com/BinHPdev/awesome-algorithm-auto-tools"
24+
RUNNER_TOKEN="YOUR_RUNNER_TOKEN_FROM_GITHUB"
25+
RUNNER_NAME="algo-tools-runner"
26+
RUNNER_DIR="$HOME/actions-runner-algo"
27+
28+
echo "======================================"
29+
echo " Awesome Algorithm Auto Tools Runner"
30+
echo "======================================"
31+
32+
command -v claude >/dev/null || { echo "❌ 需要安装 Claude Code"; exit 1; }
33+
command -v git >/dev/null || { echo "❌ 需要安装 git"; exit 1; }
34+
35+
mkdir -p "$RUNNER_DIR"
36+
cd "$RUNNER_DIR"
37+
38+
RUNNER_VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | grep '"tag_name"' | sed 's/.*"v\([^"]*\)".*/\1/')
39+
ARCH=$(uname -m)
40+
if [ "$ARCH" = "x86_64" ]; then
41+
PKG="actions-runner-osx-x64-${RUNNER_VERSION}.tar.gz"
42+
else
43+
PKG="actions-runner-osx-arm64-${RUNNER_VERSION}.tar.gz"
44+
fi
45+
46+
if [ ! -f "run.sh" ]; then
47+
echo "📦 下载 Runner v${RUNNER_VERSION}..."
48+
curl -sOL "https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/${PKG}"
49+
tar xzf "$PKG"
50+
rm "$PKG"
51+
fi
52+
53+
echo "⚙️ 配置..."
54+
./config.sh \
55+
--url "$GITHUB_REPO" \
56+
--token "$RUNNER_TOKEN" \
57+
--name "$RUNNER_NAME" \
58+
--labels "self-hosted,macos" \
59+
--work "_work" \
60+
--unattended \
61+
--replace
62+
63+
echo "🚀 安装为系统服务..."
64+
./svc.sh install
65+
./svc.sh start
66+
67+
echo ""
68+
echo "======================================"
69+
echo " ✅ Runner 安装完成!"
70+
echo " 状态: cd $RUNNER_DIR && ./svc.sh status"
71+
echo " 每周五中午会自动运行更新"
72+
echo "======================================"

scripts/weekly-update.sh

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

0 commit comments

Comments
 (0)