upstream-check.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # 定时检查 dsh 上游版本:有新版本 → 提升版本号 → 构建冒烟测试 → 通过则推送 master,失败则创建 Issue
  2. # 推送 master 会触发 docker-build.yml 自动构建 GHCR 镜像,形成「升级 → 发布」闭环
  3. #
  4. # Scheduled dsh upstream check: bump version on update → build & smoke test → push master on success, open an Issue on failure
  5. # Pushing to master triggers docker-build.yml, which builds GHCR images — an "upgrade → release" loop
  6. name: check-dsh-upstream
  7. on:
  8. schedule:
  9. # 每日 UTC 03:00(北京时间 11:00)
  10. #
  11. # Daily 03:00 UTC (11:00 Beijing time)
  12. - cron: "0 3 * * *"
  13. workflow_dispatch:
  14. permissions:
  15. contents: read
  16. concurrency:
  17. group: check-dsh-upstream
  18. cancel-in-progress: false
  19. jobs:
  20. check:
  21. runs-on: ubuntu-latest
  22. permissions:
  23. contents: read
  24. issues: read
  25. outputs:
  26. current: ${{ steps.check.outputs.current }}
  27. latest: ${{ steps.check.outputs.latest }}
  28. should_upgrade: ${{ steps.check.outputs.should_upgrade }}
  29. blocked: ${{ steps.gate.outputs.blocked }}
  30. steps:
  31. - uses: actions/checkout@v4
  32. - name: 查询上游版本并比较
  33. id: check
  34. run: |
  35. scripts/check-upstream.sh | tee -a "$GITHUB_OUTPUT"
  36. # 门闩:同版本已有未关闭的失败 Issue 时跳过自动升级(npm 包版本不可变,重试必失败)
  37. # 仅定时触发生效;手动触发(workflow_dispatch)绕过,用于人工重试环境性失败
  38. #
  39. # Gate: skip auto-upgrade when an open failure Issue exists for this version (npm versions are immutable, retry is doomed)
  40. # Only applies to schedule runs; manual dispatch bypasses it for human-driven retries
  41. - name: 门闩检查:同版本失败 Issue
  42. id: gate
  43. if: steps.check.outputs.should_upgrade == 'true' && github.event_name == 'schedule'
  44. run: |
  45. BLOCKED="$(scripts/check-issue-gate.sh "$LATEST")"
  46. echo "blocked=$BLOCKED" >> "$GITHUB_OUTPUT"
  47. if [ "$BLOCKED" = "1" ]; then
  48. echo "存在 $LATEST 的未关闭失败 Issue,跳过本次自动升级(可手动触发强制重试)"
  49. fi
  50. env:
  51. LATEST: ${{ steps.check.outputs.latest }}
  52. - name: 打印检查结果
  53. run: |
  54. echo "当前版本 (current): ${{ steps.check.outputs.current }}"
  55. echo "上游最新 (latest): ${{ steps.check.outputs.latest }}"
  56. echo "需要升级 (upgrade): ${{ steps.check.outputs.should_upgrade }}"
  57. echo "被门闩拦截 (blocked): ${{ steps.gate.outputs.blocked }}"
  58. upgrade:
  59. needs: check
  60. if: needs.check.outputs.should_upgrade == 'true' && needs.check.outputs.blocked != 'true'
  61. runs-on: ubuntu-latest
  62. permissions:
  63. contents: write
  64. issues: write
  65. steps:
  66. - uses: actions/checkout@v4
  67. - name: 提升版本号(Dockerfile / compose / README 双语)
  68. run: |
  69. scripts/upgrade-dsh.sh "$LATEST"
  70. env:
  71. LATEST: ${{ needs.check.outputs.latest }}
  72. - name: 构建镜像并冒烟测试
  73. id: smoke
  74. run: |
  75. scripts/smoke-test.sh "$LATEST"
  76. env:
  77. LATEST: ${{ needs.check.outputs.latest }}
  78. - name: 推送升级至 master
  79. run: |
  80. git config user.name "github-actions[bot]"
  81. git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
  82. git add Dockerfile docker-compose.yml README.md README.zh.md
  83. git commit -m "【维护,构建】升级 dsh 版本至 $LATEST"
  84. git push origin master
  85. env:
  86. LATEST: ${{ needs.check.outputs.latest }}
  87. # 升级已成功:旧版本的失败 Issue 均已过时,关闭以免陈旧累积
  88. # continue-on-error:清理失败不影响升级结果(不触发下方 failure() 步骤)
  89. #
  90. # The upgrade succeeded: failure Issues for older versions are stale; close them to avoid accumulation
  91. # continue-on-error: cleanup failure must not fail the upgrade (must not trigger the failure() step below)
  92. - name: 关闭过时的失败 Issue
  93. continue-on-error: true
  94. run: |
  95. scripts/close-stale-issues.sh
  96. env:
  97. LATEST: ${{ needs.check.outputs.latest }}
  98. - name: 失败时创建 Issue(同版本去重)
  99. if: failure()
  100. run: |
  101. scripts/open-issue.sh "$LATEST" "$CURRENT"
  102. env:
  103. LATEST: ${{ needs.check.outputs.latest }}
  104. CURRENT: ${{ needs.check.outputs.current }}