add debug output for readability

This commit is contained in:
Radosław Kukuczka
2025-03-30 12:39:20 +02:00
parent e2430fc590
commit a423990af9

View File

@@ -45,6 +45,12 @@ runs:
run: |
set -euo pipefail
echo "DEBUG: Starting directory preparation step"
echo "DEBUG: Remote host: ${{ inputs.ssh_host }}"
echo "DEBUG: Remote user: ${{ inputs.ssh_user }}"
echo "DEBUG: Remote base path: ${{ inputs.remote_base_path }}"
echo "DEBUG: Directory prefix: '${{ inputs.dir_prefix }}'"
if [ -z "${{ inputs.directories }}" ]; then
echo "DEBUG: No directories specified. Skipping directory creation."
echo "created_paths=" >> $GITHUB_OUTPUT
@@ -61,6 +67,8 @@ runs:
REMOTE_BASE="${{ inputs.remote_base_path }}"
while IFS= read -r LOCAL_DIR || [ -n "$LOCAL_DIR" ]; do
echo "DEBUG: Processing local directory: '$LOCAL_DIR'"
if [ -d "$LOCAL_DIR" ]; then
REMOTE_DIR="$REMOTE_BASE"
if [ -n "$PREFIX" ]; then
@@ -68,14 +76,20 @@ runs:
fi
REMOTE_DIR="$REMOTE_DIR/$LOCAL_DIR"
echo "DEBUG: Creating remote directory $REMOTE_DIR"
echo "DEBUG: Ensuring remote directory exists: '$REMOTE_DIR'"
ssh -o StrictHostKeyChecking=no -i "$SSH_KEY_FILE" \
"${{ inputs.ssh_user }}@${{ inputs.ssh_host }}" \
"mkdir -p '$REMOTE_DIR' && chmod -R 755 '$REMOTE_DIR'"
echo "DEBUG: Remote directory '$REMOTE_DIR' created and permissions set"
echo "DEBUG: Copying contents from local '$LOCAL_DIR' to remote '$REMOTE_DIR'"
if compgen -G "$LOCAL_DIR/*" > /dev/null; then
scp -o StrictHostKeyChecking=no -i "$SSH_KEY_FILE" -r "$LOCAL_DIR/"* \
${{ inputs.ssh_user }}@${{ inputs.ssh_host }}:"$REMOTE_DIR/" || echo "DEBUG: No files to copy in '$LOCAL_DIR'"
${{ inputs.ssh_user }}@${{ inputs.ssh_host }}:"$REMOTE_DIR/"
echo "DEBUG: Files from '$LOCAL_DIR' copied successfully to '$REMOTE_DIR'"
else
echo "DEBUG: No files found in '$LOCAL_DIR' to copy"
fi
CREATED_PATHS+="$REMOTE_DIR"$'\n'
else
@@ -83,9 +97,15 @@ runs:
fi
done <<< "${{ inputs.directories }}"
echo "DEBUG: Cleaning up temporary SSH key file"
echo "DEBUG: Cleaning up temporary SSH key file at $SSH_KEY_FILE"
rm -f "$SSH_KEY_FILE"
echo "DEBUG: Temporary SSH key file removed"
echo "DEBUG: All directories processed. Created paths:"
echo "$CREATED_PATHS"
echo "created_paths<<EOF" >> $GITHUB_OUTPUT
echo "$CREATED_PATHS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "DEBUG: Directory preparation step completed successfully"