From 9a7da82eb32c6049c1b1f65519cd967141f65f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Kukuczka?= Date: Sun, 30 Mar 2025 12:43:04 +0200 Subject: [PATCH] use stack name to create the directory exclusively for current stack --- action.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 00042f1..f2ecea9 100644 --- a/action.yml +++ b/action.yml @@ -1,10 +1,13 @@ name: 'Prepare Remote NFS Directories' description: | Creates specified directories on a remote NFS-mounted server via SSH. - Optionally prefixes directories with a provided short SHA to isolate deployments. + Uses stack_name and optional short SHA to isolate deployments. Skips execution if no directories are specified. inputs: + stack_name: + description: 'Stack name to prefix remote directories' + required: true ssh_host: description: 'SSH host of the remote server' required: true @@ -49,7 +52,8 @@ runs: 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 }}'" + echo "DEBUG: Stack name: ${{ inputs.stack_name }}" + echo "DEBUG: Directory prefix (short SHA): '${{ inputs.dir_prefix }}'" if [ -z "${{ inputs.directories }}" ]; then echo "DEBUG: No directories specified. Skipping directory creation." @@ -63,18 +67,24 @@ runs: echo "DEBUG: Temporary SSH key created at $SSH_KEY_FILE" CREATED_PATHS="" - PREFIX="${{ inputs.dir_prefix }}" REMOTE_BASE="${{ inputs.remote_base_path }}" + STACK_NAME="${{ inputs.stack_name }}" + PREFIX="${{ inputs.dir_prefix }}" + + # Build the root directory path + if [ -n "$PREFIX" ]; then + ROOT_DIR="$REMOTE_BASE/${STACK_NAME}-${PREFIX}" + else + ROOT_DIR="$REMOTE_BASE/${STACK_NAME}" + fi + + echo "DEBUG: Root remote directory: '$ROOT_DIR'" 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 - REMOTE_DIR="$REMOTE_DIR/$PREFIX" - fi - REMOTE_DIR="$REMOTE_DIR/$LOCAL_DIR" + REMOTE_DIR="$ROOT_DIR/$LOCAL_DIR" echo "DEBUG: Ensuring remote directory exists: '$REMOTE_DIR'" ssh -o StrictHostKeyChecking=no -i "$SSH_KEY_FILE" \