Files
openclaw/.github/actions/prepare-testbox-shell/action.yml

45 lines
1.4 KiB
YAML

name: Prepare Testbox shell
description: Pin the checked-out base ref and expose the setup-node toolchain to Testbox.
inputs:
base-ref:
description: Commit or ref that Testbox should treat as origin/main; defaults to HEAD.
required: false
runs:
using: composite
steps:
- name: Pin Testbox base and Node tools
shell: bash
env:
TESTBOX_BASE_REF: ${{ inputs.base-ref }}
run: |
set -euo pipefail
base_ref="${TESTBOX_BASE_REF:-HEAD}"
if ! base_sha="$(git rev-parse --verify "${base_ref}^{commit}")"; then
echo "Testbox base commit is missing from the maintained checkout: $base_ref" >&2
exit 1
fi
git update-ref refs/remotes/origin/main "$base_sha"
node_bin="$(dirname "$(node -p 'process.execPath')")"
link_node_tool() {
local tool="$1"
local source="$node_bin/$tool"
local target="/usr/local/bin/$tool"
if [ -e "$target" ] && [ "$(readlink -f "$source")" = "$(readlink -f "$target")" ]; then
return
fi
sudo ln -sf "$source" "$target"
}
link_node_tool node
link_node_tool npm
link_node_tool npx
link_node_tool corepack
sudo tee /usr/local/bin/pnpm >/dev/null <<'PNPM'
#!/usr/bin/env bash
exec /usr/local/bin/corepack pnpm "$@"
PNPM
sudo chmod 0755 /usr/local/bin/pnpm