Update Redemption Codes #200
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: | |
| set-timestamp: | |
| uses: ./.github/workflows/common-set-timestamp.yml | |
| update-redemption-codes: | |
| needs: set-timestamp | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| 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: Push changes | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: actions-js/push@v1.5 | |
| with: | |
| rebase: true | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| branch: ${{ github.head_ref || github.ref_name }} | |
| message: | | |
| ci: 自动更新兑换码 ${{ needs.set-timestamp.outputs.build_timestamp }} | |
| [skip ci] |