Skip to content

Update update-rules.yml #10

Update update-rules.yml

Update update-rules.yml #10

Workflow file for this run

name: 更新 Clash 规则
on:
push:
paths:
- 'rule_sources.conf' # 当配置文件被修改时触发
- 'update_rules.py' # 当脚本被修改时触发
- '.github/workflows/update-rules.yml' # 当工作流文件被修改时触发
schedule:
- cron: '0 17 * * *' # 每天 UTC 时间 16:00 运行,对应北京时间 0:00
workflow_dispatch: # 允许手动触发
jobs:
update-rules:
runs-on: ubuntu-latest
steps:
- name: 检出仓库
uses: actions/checkout@v3
- name: 设置 Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: 安装依赖
run: |
python -m pip install --upgrade pip
pip install requests pytz
- name: 运行更新脚本
run: python update_rules.py
- name: 显示目录结构
run: |
echo "当前目录结构:"
find . -type f -not -path "*/\.*" | sort
- name: 提交并推送更改
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
git status # 显示哪些文件被修改
git diff --quiet && git diff --staged --quiet || (git commit -m "更新规则 - $(date +'%Y-%m-%d')" && git push)
- name: 删除工作流运行
uses: GitRML/delete-workflow-runs@main
with:
retain_days: 5
keep_minimum_runs: 10