check_mcversion.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. pip install Pillow
  26. - name: 运行更新脚本
  27. id: run_script
  28. run: python Actions/check_mcv.py >> "$GITHUB_ENV"
  29. env:
  30. R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
  31. R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
  32. R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
  33. - name: 显示版本信息
  34. run: |
  35. printf '● 最新 %s 版: %s %s\n' "$latest_release_type" "$latest_release_id"
  36. printf '● 最新 %s 版: %s %s\n' "$latest_snapshot_type" "$latest_snapshot_id"
  37. - name: 配置 Git 信息
  38. if: ${{ env.require_update }}
  39. run: |
  40. git config --local user.email "[email protected]"
  41. git config --local user.name "Hilda Bot"
  42. - name: 配置 GPG 信息
  43. if: ${{ env.require_update }}
  44. uses: crazy-max/ghaction-import-gpg@v6
  45. with:
  46. gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
  47. git_user_signingkey: true
  48. git_commit_gpgsign: true
  49. - name: 提交与推送更改
  50. if: ${{ env.require_update }}
  51. run: |
  52. git add *
  53. git diff-index --quiet HEAD || git commit -S -m "preloaded new version" && git push
  54. - name: 显示报错信息
  55. if: ${{ failure() && steps.run_script.conclusion == 'failure' }}
  56. run: |
  57. printf '获取版本列表失败: %s' "$error_log"