更新规则集 #357
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 更新规则集 | |
| on: | |
| schedule: | |
| - cron: '0 3 * * *' # 每天 UTC 时间 3:00(北京时间 11:00)运行 | |
| workflow_dispatch: # 允许手动触发 | |
| # 添加权限配置 | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-rules: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 获取完整历史记录以确保所有文件都被检出 | |
| - name: 设置 Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: 安装依赖 | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests pyyaml | |
| - name: 下载所有规则文件 | |
| run: | | |
| chmod +x scripts/update_rules.sh | |
| ./scripts/update_rules.sh | |
| - name: 合并和更新规则列表 | |
| env: | |
| BARK_URL: ${{ secrets.BARK_URL }} | |
| run: | | |
| # 即使Bark通知失败也继续执行 | |
| python scripts/consolidate_rules.py update --notify || echo "规则更新完成,但通知可能失败" | |
| - name: 提交更改 | |
| run: | | |
| git config --local user.name "GitHub Action" | |
| git config --local user.email "[email protected]" | |
| # 添加所有更改的规则目录和统计文件 | |
| git add rulesets/ rule_stats.json | |
| # 检查是否有更改需要提交 | |
| if git diff --staged --quiet; then | |
| echo "没有规则变更,无需提交" | |
| else | |
| git commit -m "自动化: 更新规则 $(date +'%Y-%m-%d %H:%M:%S')" | |
| git push | |
| fi |