use stack name to create the directory exclusively for current stack
This commit is contained in:
26
action.yml
26
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" \
|
||||
|
||||
Reference in New Issue
Block a user