Update WeChat JSAPI Ticket #214
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 WeChat JSAPI Ticket | |
| on: | |
| schedule: | |
| # 每两小时执行一次 (UTC时间) | |
| - cron: '0 */2 * * *' | |
| workflow_dispatch: # 允许手动触发 | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-jsapi-ticket: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests | |
| - name: Update JSAPI Ticket | |
| env: | |
| WECHAT_APP_ID: ${{ secrets.WECHAT_APP_ID }} | |
| WECHAT_APP_SECRET: ${{ secrets.WECHAT_APP_SECRET }} | |
| run: | | |
| python WeChatAccess.py | |
| - name: Check for changes | |
| id: verify-changed-files | |
| run: | | |
| git diff --quiet || echo "changed=true" >> $GITHUB_OUTPUT | |
| - name: Commit and push changes | |
| if: steps.verify-changed-files.outputs.changed == 'true' | |
| run: | | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add static/js-helper/wx-share.js | |
| git commit -m "🤖 自动更新微信JSAPI Ticket" | |
| git push | |
| - name: No changes detected | |
| if: steps.verify-changed-files.outputs.changed != 'true' | |
| run: | | |
| echo "没有检测到文件变化,跳过提交" |