Update Redemption Codes #2
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: Update Redemption Codes | |
| on: | |
| schedule: | |
| # 每天晚上9点运行(北京时间 UTC+8,即 UTC 13:00) | |
| - cron: '0 13 * * *' | |
| workflow_dispatch: # 允许手动触发 | |
| jobs: | |
| update-redemption-codes: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyyaml | |
| - name: Run update redemption codes script | |
| run: | | |
| python tools/ci/update_redemption_code.py | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet config/redemption_codes.sample.yml; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push changes | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add config/redemption_codes.sample.yml | |
| git commit -m "Update redemption codes [skip ci]" || exit 0 | |
| git push |