Skip to content

Auto Update Config #979

Auto Update Config

Auto Update Config #979

name: Auto Update Config
on:
schedule:
- cron: '*/30 * * * *' # 每半小时自动运行(UTC时间)
workflow_dispatch: # 支持手动触发
jobs:
update-config:
runs-on: ubuntu-latest
steps:
# 1. 检出代码仓库
- name: Checkout Repository
uses: actions/checkout@v3
# 2. 列出文件,确认路径正确
- name: List Files (Debugging Step)
run: |
ls -al xray/2/ # 确认文件存在
# 3. 设置 Python 环境
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
# 4. 安装 Python 依赖
- name: Install Dependencies
run: |
pip install pytz # 如有其他依赖,可以在这里添加
# 5. 执行更新脚本
- name: Run Update Script
run: |
python xray/2/update_config.py
# 6. 提交并推送更改到远程仓库
- name: Commit and Push Changes
run: |
git config --local user.name "github-actions"
git config --local user.email "actions@github.com"
# 先暂存更改,确保工作目录干净
git add xray/2/config.json
# 如果有更改,先提交,再拉取并推送
git commit -m "Auto-update config.json: Increment domains" || echo "No changes to commit"
# 拉取远程更新并合并
git pull --rebase --autostash
# 推送到远程仓库
git push