ci: remove debug workflow - runner-fix-final.yml
Fix Simple / fix (push) Failing after 0s
Diag SaaS Runner / diag (push) Failing after 2s
Add Unique Tag / add-tag (push) Successful in 1s

This commit is contained in:
2026-07-12 10:25:57 +08:00
parent 6a5082a805
commit b992f99f25
-145
View File
@@ -1,145 +0,0 @@
name: Runner Final Fix
on:
push:
branches:
- ci/runner-fix
jobs:
fix-labels:
runs-on: host
steps:
- name: 统一3个runner标签 + 清理offline旧runner
run: |
set -e
CI_DIR="/var/lib/xiaoxia-ci"
GITEA_URL="https://git.xiaoxiajianji.com"
GITEA_TOKEN="1f8058d097e3942a9ed31c44382baf7f08311272"
echo "========== 1. 停止所有runner服务 =========="
systemctl stop act_runner.service act_runner-2.service act_runner-3.service
sleep 2
echo "done"
echo ""
echo "========== 2. 统一主runner标签(修改.runner JSON)=========="
if [ -f "$CI_DIR/.runner" ]; then
python3 << PYEOF
import json
with open("$CI_DIR/.runner") as f:
cfg = json.load(f)
# 统一标签:所有runner都有 saas + runtime-builder + host + ubuntu-latest
cfg["labels"] = ["saas", "runtime-builder", "host", "ubuntu-latest"]
with open("$CI_DIR/.runner", "w") as f:
json.dump(cfg, f, indent=2)
print(f"主runner labels updated: {cfg['labels']}")
PYEOF
else
echo "主runner .runner 文件不存在,检查config"
ls -la "$CI_DIR/.runner"* 2>/dev/null || true
fi
echo ""
echo "========== 3. 统一 runner-2 标签 =========="
python3 << PYEOF
import json
with open("$CI_DIR/runner-2/.runner") as f:
cfg = json.load(f)
cfg["labels"] = ["saas", "runtime-builder", "host", "ubuntu-latest"]
with open("$CI_DIR/runner-2/.runner", "w") as f:
json.dump(cfg, f, indent=2)
print(f"runner-2 labels updated: {cfg['labels']}")
PYEOF
echo ""
echo "========== 4. 统一 runner-3 标签 =========="
python3 << PYEOF
import json
with open("$CI_DIR/runner-3/.runner") as f:
cfg = json.load(f)
cfg["labels"] = ["saas", "runtime-builder", "host", "ubuntu-latest"]
with open("$CI_DIR/runner-3/.runner", "w") as f:
json.dump(cfg, f, indent=2)
print(f"runner-3 labels updated: {cfg['labels']}")
PYEOF
echo ""
echo "========== 5. 启动所有runner服务 =========="
systemctl start act_runner.service act_runner-2.service act_runner-3.service
sleep 5
systemctl status act_runner.service --no-pager | head -5
systemctl status act_runner-2.service --no-pager | head -5
systemctl status act_runner-3.service --no-pager | head -5
echo ""
echo "========== 6. 清理offline旧runner =========="
# 获取所有runner列表,删除offline的
python3 << PYEOF
import urllib.request, json, ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
req = urllib.request.Request(
f"{GITEA_URL}/api/v1/repos/xiaoxia/xiaoxia-saas/actions/runners?limit=50",
headers={"Authorization": f"token {GITEA_TOKEN}"}
)
resp = urllib.request.urlopen(req, context=ctx)
data = json.loads(resp.read())
print("当前所有runner:")
for r in data.get("runners", []):
print(f" id={r['id']} name={r['name']} status={r['status']} labels={[l['name'] for l in r['labels']]}")
# 删除offline的
deleted = 0
for r in data.get("runners", []):
if r["status"] == "offline":
del_req = urllib.request.Request(
f"{GITEA_URL}/api/v1/repos/xiaoxia/xiaoxia-saas/actions/runners/{r['id']}",
headers={"Authorization": f"token {GITEA_TOKEN}"},
method="DELETE"
)
try:
urllib.request.urlopen(del_req, context=ctx)
print(f" 已删除 offline runner: id={r['id']} name={r['name']}")
deleted += 1
except Exception as e:
print(f" 删除失败 id={r['id']}: {e}")
print(f"\n共删除 {deleted} 个 offline runner")
PYEOF
echo ""
echo "========== 7. 等待10秒后验证最终状态 =========="
sleep 10
python3 << PYEOF
import urllib.request, json, ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
req = urllib.request.Request(
f"{GITEA_URL}/api/v1/repos/xiaoxia/xiaoxia-saas/actions/runners?limit=20",
headers={"Authorization": f"token {GITEA_TOKEN}"}
)
resp = urllib.request.urlopen(req, context=ctx)
data = json.loads(resp.read())
print("最终runner状态:")
online_count = 0
for r in data.get("runners", []):
if r["status"] == "online":
online_count += 1
print(f" id={r['id']} name={r['name']} status={r['status']} busy={r['busy']} labels={[l['name'] for l in r['labels']]}")
print(f"\n✅ 在线runner数量: {online_count}")
if online_count == 3:
print("✅ 扩容成功:3个runner全部在线")
else:
print(f"⚠️ 预期3个,实际{online_count}个在线")
PYEOF
echo ""
echo "========== 全部完成 =========="