check_mcversion.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: Check Minecraft Version
  2. on:
  3. schedule:
  4. - cron: '0/15 13-18 * * *'
  5. - cron: '0 0,4,8,12 * * *'
  6. - cron: '0 19,20,22 * * *'
  7. workflow_dispatch:
  8. jobs:
  9. check_mcv:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: 签出储存库
  13. uses: actions/checkout@v4
  14. - name: 配置 Python 环境
  15. uses: actions/setup-python@v4
  16. with:
  17. python-version: 3.11
  18. - name: 安装依赖
  19. run: |
  20. python -m pip install --upgrade pip
  21. pip install requests
  22. pip install botocore
  23. pip install boto3
  24. pip install beautifulsoup4
  25. - name: 运行更新脚本
  26. id: run_script
  27. run: python Actions/check_mcv.py >> "$GITHUB_ENV"
  28. env:
  29. R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
  30. R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
  31. R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
  32. - name: 显示版本信息
  33. run: |
  34. printf '● 最新 %s 版: %s %s\n' "$latest_release_type" "$latest_release_id"
  35. printf '● 最新 %s 版: %s %s\n' "$latest_snapshot_type" "$latest_snapshot_id"
  36. - name: 配置 Git 信息
  37. if: ${{ env.require_update }}
  38. run: |
  39. git config --local user.email "[email protected]"
  40. git config --local user.name "Hilda Bot"
  41. - name: 配置 GPG 信息
  42. if: ${{ env.require_update }}
  43. uses: crazy-max/ghaction-import-gpg@v6
  44. with:
  45. gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
  46. git_user_signingkey: true
  47. git_commit_gpgsign: true
  48. - name: 提交与推送更改
  49. if: ${{ env.require_update }}
  50. run: |
  51. git add *
  52. git diff-index --quiet HEAD || git commit -S -m "preloaded new version" && git push
  53. - name: 显示报错信息
  54. if: ${{ failure() && steps.run_script.conclusion == 'failure' }}
  55. run: |
  56. printf '获取版本列表失败: %s' "$error_log"