fix: mktemp wrapper creation and register custom shell via mapping

This commit is contained in:
Karolis2011 2025-11-20 00:14:48 +02:00
parent e20d2c2744
commit 8b0eaf3b2a

View file

@ -157,7 +157,7 @@ runs:
TEMP_DIR="${RUNNER_TEMP:-/tmp}" TEMP_DIR="${RUNNER_TEMP:-/tmp}"
WRAPPER_DIR=$(mktemp -d "$TEMP_DIR/setup-ssh-client-XXXXXX") WRAPPER_DIR=$(mktemp -d "$TEMP_DIR/setup-ssh-client-XXXXXX")
mkdir -p "$WRAPPER_DIR" mkdir -p "$WRAPPER_DIR"
WRAPPER_PATH="$WRAPPER_DIR/ssh-remote-shell.sh" WRAPPER_PATH="$(mktemp "$WRAPPER_DIR/ssh-remote-shell-XXXXXX.sh")"
cat << 'WRAPPER_EOF' > "$WRAPPER_PATH" cat << 'WRAPPER_EOF' > "$WRAPPER_PATH"
#!/bin/bash #!/bin/bash
@ -180,6 +180,7 @@ runs:
# Execute script on remote server # Execute script on remote server
# Use BatchMode to prevent interactive prompts # Use BatchMode to prevent interactive prompts
# ConnectTimeout to fail fast if connection issues # ConnectTimeout to fail fast if connection issues
echo "Executing script on remote server '${{ inputs.ssh-host }}' via SSH..."
ssh -o BatchMode=yes \ ssh -o BatchMode=yes \
-o ConnectTimeout=10 \ -o ConnectTimeout=10 \
github-action-host \ github-action-host \
@ -207,8 +208,9 @@ runs:
shell: bash shell: bash
run: | run: |
SHELL_WRAPPER_PATH="${{ steps.setup-shell-wrapper.outputs.shell-wrapper-path }}" SHELL_WRAPPER_PATH="${{ steps.setup-shell-wrapper.outputs.shell-wrapper-path }}"
# Register custom shell for this job by setting a custom shell mapping # Register custom shell for this job by mapping the shell name to the
# in $GITHUB_ENV. This maps the shell name to the path. The runner will # wrapper path. This is the recommended way to expose a custom shell
# use the provided script path when 'shell: ssh-remote' is used in steps. # for `shell: ssh-remote` in subsequent steps. We do this conditionally
# so `use-shell-wrapper` can be used to opt out.
echo "ssh-remote=$SHELL_WRAPPER_PATH {0}" >> "$GITHUB_ENV" echo "ssh-remote=$SHELL_WRAPPER_PATH {0}" >> "$GITHUB_ENV"
echo "✅ Custom shell 'ssh-remote' registered for this job" echo "✅ Custom shell 'ssh-remote' registered for this job"