fix: entrypoint.sh is not executable, every run fails with exit 126 #1

Merged
fmartingr merged 2 commits from butterrobot/fix-entrypoint-exec-bit into main 2026-09-09 19:53:12 +02:00 AGit
2 changed files with 15 additions and 9 deletions

View file

@ -41,7 +41,7 @@ runs:
fi
- name: Deploy
shell: sh
run: ${{ github.action_path }}/entrypoint.sh
run: sh "${{ github.action_path }}/entrypoint.sh"
env:
INPUT_HOST: ${{ inputs.host }}
INPUT_PORT: ${{ inputs.port }}

22
entrypoint.sh Normal file → Executable file
View file

@ -24,20 +24,26 @@ fi
SSH_PORT="${INPUT_PORT:-22}"
SOURCE="${INPUT_SOURCE:-.}"
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# ssh expands ~ from the passwd database rather than $HOME, so the two disagree
# whenever a container sets HOME elsewhere. Pass absolute paths instead.
SSH_DIR="$HOME/.ssh"
KEY_FILE="$SSH_DIR/deploy_key"
KNOWN_HOSTS="$SSH_DIR/known_hosts"
echo "$INPUT_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
mkdir -p "$SSH_DIR"
chmod 700 "$SSH_DIR"
ssh-keyscan -p "$SSH_PORT" -H "$INPUT_HOST" >> ~/.ssh/known_hosts 2>/dev/null
trap 'rm -f "$KEY_FILE"' EXIT
echo "$INPUT_KEY" > "$KEY_FILE"
chmod 600 "$KEY_FILE"
ssh-keyscan -p "$SSH_PORT" -H "$INPUT_HOST" >> "$KNOWN_HOSTS" 2>/dev/null
rsync -avz \
-e "ssh -i ~/.ssh/deploy_key -p $SSH_PORT -o ConnectTimeout=30" \
-e "ssh -i $KEY_FILE -o UserKnownHostsFile=$KNOWN_HOSTS -p $SSH_PORT -o ConnectTimeout=30" \
$INPUT_ARGS \
"${SOURCE}/" \
"${INPUT_USERNAME}@${INPUT_HOST}:${INPUT_TARGET}/"
rm -f ~/.ssh/deploy_key
echo "Deployed ${SOURCE} to ${INPUT_HOST}:${INPUT_TARGET}"