-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
47 lines (46 loc) · 1.79 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: IMS - SFTP Action
branding:
icon: server
color: orange
description: |
This GitHub Action allows you to upload files recursively using FTP/SFTP to an IMS network server.
It reads the specified local directory and uploads its contents to the provided SFTP server URL.
author: ims-network
inputs:
username:
description: 'Username for the SFTP server.'
required: true
password:
description: 'Password for the SFTP server.'
required: true
server:
description: 'SFTP server address. Example: example.com'
required: true
port:
description: 'SFTP server port.'
required: true
remote-directory:
description: 'Remote directory on the SFTP server to upload files to.'
required: true
local-directory:
description: 'The directory that should be uploaded.'
required: true
runs:
using: 'composite'
steps:
- name: Set environment variables
run: |
echo "INPUT_USERNAME=${{ inputs.username }}" >> $GITHUB_ENV
echo "INPUT_PASSWORD=${{ inputs.password }}" >> $GITHUB_ENV
echo "INPUT_SERVER=${{ inputs.server }}" >> $GITHUB_ENV
echo "INPUT_PORT=${{ inputs.port }}" >> $GITHUB_ENV
echo "INPUT_REMOTE_DIRECTORY=${{ inputs.remote-directory }}" >> $GITHUB_ENV
echo "INPUT_LOCAL_DIRECTORY=${{ inputs.local-directory }}" >> $GITHUB_ENV
shell: bash
- name: Upload files using SFTP
run: |
# Debugging line
echo "Constructed URL: sftp://$INPUT_SERVER:$INPUT_PORT$INPUT_REMOTE_DIRECTORY/$(basename $INPUT_LOCAL_DIRECTORY)"
# Use curl to upload the files
find $INPUT_LOCAL_DIRECTORY -type f -exec bash -c 'curl -k -u $INPUT_USERNAME:$INPUT_PASSWORD --disable-epsv --ftp-method nocwd -T {} sftp://$INPUT_SERVER:$INPUT_PORT$INPUT_REMOTE_DIRECTORY/$(basename {})' \;
shell: bash