ci: remove debug workflow - fix-labels-now.yml
This commit is contained in:
@@ -1,105 +0,0 @@
|
||||
name: Fix Runner Labels Now
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- ci/runner-fix
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
do-fix:
|
||||
runs-on: saas
|
||||
steps:
|
||||
- name: 执行标签修复
|
||||
run: |
|
||||
set -ex
|
||||
CI_DIR="/var/lib/xiaoxia-ci"
|
||||
ACT_BIN="$CI_DIR/act_runner"
|
||||
GITEA_URL="https://git.xiaoxiajianji.com"
|
||||
LABELS="saas,runtime-builder,host,ubuntu-latest"
|
||||
TOKEN="1f8058d097e3942a9ed31c44382baf7f08311272"
|
||||
|
||||
echo "=== Step 1: Get registration token ==="
|
||||
REG_TOKEN=$(curl -sk -X POST -H "Authorization: token $TOKEN" \
|
||||
"$GITEA_URL/api/v1/repos/xiaoxia/xiaoxia-saas/actions/runners/registration-token" \
|
||||
| python3 -c "import sys,json; print(json.load(sys.stdin).get('token',''))")
|
||||
echo "Token obtained, length: ${#REG_TOKEN}"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 2: Fix main runner ==="
|
||||
systemctl stop act_runner.service
|
||||
sleep 3
|
||||
cd "$CI_DIR"
|
||||
rm -f .runner
|
||||
$ACT_BIN register --instance "$GITEA_URL" --token "$REG_TOKEN" \
|
||||
--name "xiaoxia-ci-runner" --labels "$LABELS" --no-interactive
|
||||
echo "Main runner registered"
|
||||
|
||||
# Update systemd service to use .runner file
|
||||
sed -i 's|ExecStart=.*|ExecStart=/var/lib/xiaoxia-ci/act_runner daemon -c /var/lib/xiaoxia-ci/.runner|' /etc/systemd/system/act_runner.service
|
||||
systemctl daemon-reload
|
||||
systemctl start act_runner.service
|
||||
echo "Main runner started"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 3: Fix runner-3 ==="
|
||||
systemctl stop act_runner-3.service
|
||||
sleep 3
|
||||
cd "$CI_DIR/runner-3"
|
||||
rm -f .runner
|
||||
$ACT_BIN register --instance "$GITEA_URL" --token "$REG_TOKEN" \
|
||||
--name "xiaoxia-ci-runner-3" --labels "$LABELS" --no-interactive
|
||||
systemctl start act_runner-3.service
|
||||
echo "Runner-3 started"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 4: Setup runner-2 auto-fix on next restart ==="
|
||||
# Write fix script to file
|
||||
printf '#!/bin/bash\nset -e\nCI_DIR="/var/lib/xiaoxia-ci"\nACT_BIN="$CI_DIR/act_runner"\nGITEA_URL="https://git.xiaoxiajianji.com"\nLABELS="saas,runtime-builder,host,ubuntu-latest"\nTOKEN="1f8058d097e3942a9ed31c44382baf7f08311272"\nREG_TOKEN=$(curl -sk -X POST -H "Authorization: token $TOKEN" "$GITEA_URL/api/v1/repos/xiaoxia/xiaoxia-saas/actions/runners/registration-token" | python3 -c "import sys,json; print(json.load(sys.stdin).get(chr(39)tokenchr(39),chr(39)chr(39)))")\nif [ -n "$REG_TOKEN" ]; then\n cd "$CI_DIR/runner-2"\n rm -f .runner\n $ACT_BIN register --instance "$GITEA_URL" --token "$REG_TOKEN" --name "xiaoxia-ci-runner-2" --labels "$LABELS" --no-interactive\n echo "runner-2 re-registered" >> /tmp/fix-runner2.log\nfi\n' > /tmp/fix-runner2.sh
|
||||
|
||||
# Actually let's just do it simpler - write the script using echo
|
||||
rm -f /tmp/fix-runner2.sh
|
||||
echo '#!/bin/bash' >> /tmp/fix-runner2.sh
|
||||
echo 'set -e' >> /tmp/fix-runner2.sh
|
||||
echo 'CI_DIR="/var/lib/xiaoxia-ci"' >> /tmp/fix-runner2.sh
|
||||
echo 'ACT_BIN="$CI_DIR/act_runner"' >> /tmp/fix-runner2.sh
|
||||
echo 'GITEA_URL="https://git.xiaoxiajianji.com"' >> /tmp/fix-runner2.sh
|
||||
echo 'LABELS="saas,runtime-builder,host,ubuntu-latest"' >> /tmp/fix-runner2.sh
|
||||
echo 'TOKEN="1f8058d097e3942a9ed31c44382baf7f08311272"' >> /tmp/fix-runner2.sh
|
||||
echo 'REG_TOKEN=$(curl -sk -X POST -H "Authorization: token $TOKEN" "$GITEA_URL/api/v1/repos/xiaoxia/xiaoxia-saas/actions/runners/registration-token" | python3 -c "import sys,json; print(json.load(sys.stdin).get(\"token\",\"\"))")' >> /tmp/fix-runner2.sh
|
||||
echo 'if [ -n "$REG_TOKEN" ]; then' >> /tmp/fix-runner2.sh
|
||||
echo ' cd "$CI_DIR/runner-2"' >> /tmp/fix-runner2.sh
|
||||
echo ' rm -f .runner' >> /tmp/fix-runner2.sh
|
||||
echo ' $ACT_BIN register --instance "$GITEA_URL" --token "$REG_TOKEN" --name "xiaoxia-ci-runner-2" --labels "$LABELS" --no-interactive' >> /tmp/fix-runner2.sh
|
||||
echo ' echo "runner-2 re-registered" >> /tmp/fix-runner2.log' >> /tmp/fix-runner2.sh
|
||||
echo 'fi' >> /tmp/fix-runner2.sh
|
||||
chmod +x /tmp/fix-runner2.sh
|
||||
|
||||
mkdir -p /etc/systemd/system/act_runner-2.service.d/
|
||||
echo "[Service]" > /etc/systemd/system/act_runner-2.service.d/override.conf
|
||||
echo "ExecStartPre=/tmp/fix-runner2.sh" >> /etc/systemd/system/act_runner-2.service.d/override.conf
|
||||
systemctl daemon-reload
|
||||
echo "Runner-2 auto-fix setup done"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 5: Wait for runners to connect ==="
|
||||
sleep 20
|
||||
|
||||
echo ""
|
||||
echo "=== Step 6: Verify ==="
|
||||
curl -sk -H "Authorization: token $TOKEN" \
|
||||
"$GITEA_URL/api/v1/repos/xiaoxia/xiaoxia-saas/actions/runners?limit=50" \
|
||||
| python3 -c "
|
||||
import sys, json
|
||||
data = json.load(sys.stdin)
|
||||
online = [r for r in data.get('runners', []) if r['status'] == 'online']
|
||||
print(f'Online: {len(online)}')
|
||||
for r in online:
|
||||
labels = [l['name'] for l in r['labels']]
|
||||
print(f' {r[\"name\"]}: {labels}')
|
||||
"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 7: Restart runner-2 (current runner) in background ==="
|
||||
nohup bash -c "sleep 10 && systemctl restart act_runner-2.service" > /dev/null 2>&1 &
|
||||
echo "Restart scheduled"
|
||||
echo "ALL DONE"
|
||||
Reference in New Issue
Block a user