📂 Prepare Remote NFS Directories Action
Easily create and populate remote directories on your NFS-mounted server via SSH. Perfect for isolating deployments and managing static assets or configuration files! 🚀✨
🌟 Features
- 📡 Remote Directory Creation: Automatically creates directories on your remote NFS-mounted server.
- 📂 Automatic File Copying: Copies local directory contents to remote directories.
- 🔑 Secure SSH Handling: Uses secure SSH key authentication.
- 🛠️ Flexible Directory Structure: Customize remote directory paths with stack names and optional prefixes (e.g., Git SHA).
- 📋 Detailed Debug Logs: Clear logs for easy troubleshooting.
📥 Inputs
| Input | Description | Required | Default |
|---|---|---|---|
stack_name |
Stack name to prefix remote directories | ✅ Yes | - |
ssh_host |
SSH host of the remote server | ✅ Yes | - |
ssh_user |
SSH username for the remote server | ✅ Yes | - |
ssh_key |
SSH private key for authentication | ✅ Yes | - |
directories |
Newline-separated list of local directories to create remotely and copy contents from | ❌ No | (empty) |
remote_base_path |
Base path on remote server | ❌ No | /mnt/docker-mounts |
dir_prefix |
Optional prefix for remote directories (e.g., Git short SHA) | ❌ No | (empty) |
Example for directories input:
config
public/images
public/icons
📤 Outputs
| Output | Description | Example |
|---|---|---|
created_paths |
Newline-separated list of remote directories created | /mnt/docker-mounts/my-stack/config |
🛠️ Example Usage
Here's how you can integrate this action into your workflow:
- name: Prepare Remote Directories 📂
id: prepare-remote
uses: your-org/prepare-remote-nfs-directories@main
with:
stack_name: my-awesome-stack
ssh_host: ${{ vars.SSH_HOST }}
ssh_user: ${{ secrets.SSH_USER }}
ssh_key: ${{ secrets.SSH_KEY }}
directories: |
config
public/images
public/icons
remote_base_path: /mnt/docker-mounts
dir_prefix: ${{ github.sha }}
- name: Show Created Directories 📋
run: |
echo "Directories created remotely:"
echo "${{ steps.prepare-remote.outputs.created_paths }}"
🧑💻 How It Works
This action performs the following steps:
| Step | Description |
|---|---|
| 🔑 | Securely creates a temporary SSH key file for authentication. |
| 📂 | Creates remote directories based on your inputs (stack_name, dir_prefix). |
| 📤 | Copies contents from specified local directories to remote directories. |
| 🔐 | Sets appropriate permissions (755) on remote directories. |
| 🧹 | Cleans up temporary SSH key file after completion. |
| 📋 | Provides detailed debug logs for each step. |
📖 Debugging & Logs
Detailed debug logs are provided at every step, making troubleshooting easy:
DEBUG: Starting directory preparation step
DEBUG: Remote host: my.remote.host
DEBUG: Remote user: deploy-user
DEBUG: Remote base path: /mnt/docker-mounts
DEBUG: Stack name: my-stack
DEBUG: Directory prefix: 'abc1234'
DEBUG: Processing local directory: 'config'
DEBUG: Ensuring remote directory exists: '/mnt/docker-mounts/my-stack-abc1234/config'
...
DEBUG: Directory preparation step completed successfully
⚠️ Requirements
- SSH access to your remote NFS-mounted server.
- SSH key authentication enabled.
- Local directories specified must exist and contain files you want to copy.
📜 License
This action is open-source software licensed under the MIT license.
Happy deploying! 🎉
— Grand
Description