diff --git a/.gitea/workflows/runner-maintenance.yaml b/.gitea/workflows/runner-maintenance.yaml index 39ad12f..eeb3fef 100644 --- a/.gitea/workflows/runner-maintenance.yaml +++ b/.gitea/workflows/runner-maintenance.yaml @@ -8,11 +8,16 @@ on: jobs: health-check: runs-on: docker - container: - image: alpine:3.20 steps: - name: Install tools - run: apk add --no-cache curl docker-cli grep + run: | + if command -v apk >/dev/null 2>&1; then + apk add --no-cache curl grep + elif command -v apt-get >/dev/null 2>&1; then + apt-get update -qq && apt-get install -y -qq curl grep + else + echo "No supported package manager"; exit 1 + fi - name: Check Gitea health id: gitea @@ -48,22 +53,9 @@ jobs: exit 1 fi - - name: Cleanup stale action containers - id: cleanup - run: | - REMOVED=0 - for cid in $(docker ps -a --filter "label=org.opencontainers.image.source=gitea/act_runner" -q 2>/dev/null || true); do - STATE=$(docker inspect -f '{{.State.Status}}' "$cid" 2>/dev/null || echo unknown) - if [ "$STATE" = "exited" ]; then - docker rm "$cid" >/dev/null 2>&1 && REMOVED=$((REMOVED+1)) || true - fi - done - echo "result=ok|清理 ${REMOVED} 个已退出的 job 容器" >> $GITHUB_OUTPUT - continue-on-error: true - - name: Notify DingTalk on failure if: failure() run: | curl -s -X POST "https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.DINGDING_TOKEN }}" \ -H "Content-Type: application/json" \ - -d '{"msgtype":"markdown","markdown":{"title":"❌ Gitea Runner 自主维护告警 chen-fnos","text":"## ❌ Gitea Runner 自主维护告警 chen-fnos\n\n- Gitea: ${{ steps.gitea.outputs.result }}\n- Verdaccio: ${{ steps.verdaccio.outputs.result }}\n- Runner: ${{ steps.runner.outputs.result }}\n- 清理: ${{ steps.cleanup.outputs.result }}\n\n请检查 gitea-runner 容器状态"}}' + -d '{"msgtype":"markdown","markdown":{"title":"❌ Gitea Runner 自主维护告警 chen-fnos","text":"## ❌ Gitea Runner 自主维护告警 chen-fnos\n\n- Gitea: ${{ steps.gitea.outputs.result }}\n- Verdaccio: ${{ steps.verdaccio.outputs.result }}\n- Runner: ${{ steps.runner.outputs.result }}\n\n请检查 gitea-runner 容器状态"}}'