fix: correct wrapper mktemp quote, create symlink to wrapper script, and register shell via

This commit is contained in:
Karolis2011 2025-11-20 00:07:43 +02:00
parent 763b8f8e8d
commit e20d2c2744

View file

@ -155,7 +155,7 @@ runs:
# the wrapper in the `GITHUB_WORKSPACE` to avoid polluting repo files. # the wrapper in the `GITHUB_WORKSPACE` to avoid polluting repo files.
# Prefer runner-specific temp folders (RUNNER_TEMP), then /tmp. # Prefer runner-specific temp folders (RUNNER_TEMP), then /tmp.
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="$WRAPPER_DIR/ssh-remote-shell.sh"
@ -188,9 +188,10 @@ runs:
chmod +x "$WRAPPER_PATH" chmod +x "$WRAPPER_PATH"
echo "✅ SSH remote shell wrapper created at $WRAPPER_PATH" echo "✅ SSH remote shell wrapper created at $WRAPPER_PATH"
# We also create symlink without the .sh extension for use in path # We also create symlink without the .sh extension to provide a
# short executable name inside the wrapper dir (e.g. $WRAPPER_DIR/ssh-remote)
ln -s "$WRAPPER_PATH" "$WRAPPER_DIR/ssh-remote"
if [ "${{ inputs.use-shell-wrapper }}" = "true" ]; then if [ "${{ inputs.use-shell-wrapper }}" = "true" ]; then
ln -s "$WRAPPER_DIR/ssh-remote" "$WRAPPER_PATH"
echo "" echo ""
echo "To use the remote shell in subsequent steps, add:" echo "To use the remote shell in subsequent steps, add:"
echo " shell: ssh-remote" echo " shell: ssh-remote"
@ -205,8 +206,9 @@ runs:
if: inputs.use-shell-wrapper == 'true' if: inputs.use-shell-wrapper == 'true'
shell: bash shell: bash
run: | run: |
SHELL_WRAPPER_DIR="${{ steps.setup-shell-wrapper.outputs.shell-wrapper-dir }}" SHELL_WRAPPER_PATH="${{ steps.setup-shell-wrapper.outputs.shell-wrapper-path }}"
# Register custom shell for this job # Register custom shell for this job by setting a custom shell mapping
echo "Adding custom shell 'ssh-remote' to PATH" # in $GITHUB_ENV. This maps the shell name to the path. The runner will
echo "$SHELL_WRAPPER_DIR" >> $GITHUB_PATH # use the provided script path when 'shell: ssh-remote' is used in steps.
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"