更新 Clash/CloudflareCIDR.list #3588
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: 更新 Clash/CloudflareCIDR.list | |
| on: | |
| schedule: | |
| - cron: '5 * * * 2' # 每周二 UTC 每小时第 5 分钟执行(北京时间周二 08:05 至周三 07:05,每小时一次) | |
| workflow_dispatch: # 允许手动触发 | |
| jobs: | |
| download-and-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v2 | |
| - name: Set up Python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: '3.x' # 选择 Python 版本 | |
| - name: Install requests library | |
| run: | | |
| pip install requests | |
| - name: Download File | |
| run: python CloudflareCIDR-main.py # 这里 CloudflareCIDR-main.py 处理文件 | |
| - name: Check for changes and commit | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add . | |
| # 检查是否有变更 | |
| if git diff --cached --quiet; then | |
| echo "没有文件变更,跳过提交" | |
| else | |
| echo "检测到文件变更,开始提交" | |
| git commit -m "Downloaded file on $(date "+%Y/%m/%d %H:%M:%S")" | |
| git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{github.repository}}.git | |
| git push | |
| echo "提交完成" | |
| fi |