diff --git a/scripts/setup_runner_mac.sh b/scripts/setup_runner_mac.sh index d028f36..53ddbeb 100755 --- a/scripts/setup_runner_mac.sh +++ b/scripts/setup_runner_mac.sh @@ -56,33 +56,25 @@ mkdir -p "$(dirname "$CONFIG_PATH")" "$INSTALL_DIR/act_runner" generate-config > "$CONFIG_PATH" # Patch labels, cache host/port, and capacity -python3 - "$CONFIG_PATH" "$HOST_IP" "$CACHE_PORT" <<'PYEOF' -import sys, re +awk -v host="$HOST_IP" -v port="$CACHE_PORT" ' + /^runner:/ { in_runner=1; in_cache=0 } + /^cache:/ { in_cache=1; in_runner=0 } + /^[a-z]/ && !/^runner:/ && !/^cache:/ { in_runner=0; in_cache=0 } -path, host_ip, port = sys.argv[1], sys.argv[2], sys.argv[3] -with open(path) as f: - content = f.read() + in_runner && /capacity:/ { $0 = " capacity: 1" } + in_runner && /labels:/ { print; skip_labels=1; next } + skip_labels && /^ - / { next } + skip_labels && !/^ - / { skip_labels=0 + print " - \"macos-latest:host\"" + print " - \"macos-14:host\"" } -# labels -content = re.sub( - r'(labels:\s*\n)(\s+-.*\n)+', - 'labels:\n - "macos-latest:host"\n - "macos-14:host"\n', - content -) -# cache enabled -content = re.sub(r'(cache:.*?\n\s+enabled:\s*)false', r'\g<1>true', content, flags=re.DOTALL) -# cache host -content = re.sub(r'( host:\s*)""', f' host: "{host_ip}"', content) -# cache port -content = re.sub(r'( port:\s*)\d+', f' port: {port}', content) -# capacity -content = re.sub(r'( capacity:\s*)\d+', r' capacity: 1', content) + in_cache && /enabled:/ { $0 = " enabled: true" } + in_cache && /host:/ { $0 = " host: \"" host "\"" } + in_cache && /port:/ { $0 = " port: " port; in_cache=0 } -with open(path, 'w') as f: - f.write(content) - -print(f"Config patched: labels=macos-latest:host, cache={host_ip}:{port}") -PYEOF + { print } +' "$CONFIG_PATH" > "${CONFIG_PATH}.tmp" && mv "${CONFIG_PATH}.tmp" "$CONFIG_PATH" +echo "Config patched: labels=macos-latest:host, cache=$HOST_IP:$CACHE_PORT" # ── register runner ─────────────────────────────────────────────────────────── echo "Registering runner '$RUNNER_NAME'..."