Auto Update Game CDN Rules #417
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: Auto Update Game CDN Rules | |
| on: | |
| schedule: | |
| # 每 8 小时运行一次(UTC 0:00, 8:00, 16:00) | |
| - cron: '0 */8 * * *' | |
| workflow_dispatch: # 支持手动触发 | |
| permissions: | |
| contents: write | |
| env: | |
| TARGET_BRANCH: ${{ (github.event_name == 'workflow_run' && github.event.workflow_run.head_branch) || ((github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref_name) || (vars.WORK_BRANCH != '' && vars.WORK_BRANCH) || 'main' }} | |
| jobs: | |
| update-game-cdn: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Generate Game_Download_CDN.list | |
| run: | | |
| echo "::group::Running generation script" | |
| python py/generate_game_cdn.py | |
| echo "::endgroup::" | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if git diff --quiet rule/Game_Download_CDN.list; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No changes detected in Game_Download_CDN.list" | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "Changes detected in Game_Download_CDN.list" | |
| fi | |
| - name: Commit and push changes | |
| if: steps.check_changes.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add rule/Game_Download_CDN.list | |
| git commit -m "chore(rule): auto-update Game_Download_CDN.list from upstream" | |
| git push origin main | |
| - name: No changes | |
| if: steps.check_changes.outputs.changed == 'false' | |
| run: echo "✓ Game_Download_CDN.list is already up to date" |