Compare commits
No commits in common. "master" and "v1.2.5" have entirely different histories.
|
|
@ -2,7 +2,7 @@
|
||||||
FROM alpine:3.18
|
FROM alpine:3.18
|
||||||
|
|
||||||
# Install required packages in one RUN statement to reduce image layers
|
# Install required packages in one RUN statement to reduce image layers
|
||||||
RUN apk update && apk add --no-cache rsync sshpass openssh expect
|
RUN apk update && apk add --no-cache rsync sshpass openssh
|
||||||
|
|
||||||
# Copy entrypoint script and set correct permissions
|
# Copy entrypoint script and set correct permissions
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|
|
||||||
36
README.md
36
README.md
|
|
@ -20,9 +20,8 @@
|
||||||
| `sftp_only` | no | | If your port only accepts the sftp protocol, set this option to `true`. However, when set to `true`, the remote folder won't be automatically created. |
|
| `sftp_only` | no | | If your port only accepts the sftp protocol, set this option to `true`. However, when set to `true`, the remote folder won't be automatically created. |
|
||||||
| `sftpArgs` | no | | Extra arguments you want to pass to `sftp`, for example: `-o ConnectTimeout=5` |
|
| `sftpArgs` | no | | Extra arguments you want to pass to `sftp`, for example: `-o ConnectTimeout=5` |
|
||||||
| `delete_remote_files` | no | false | Set to `true` to delete the remote path folder and all files in it **before** uploading. |
|
| `delete_remote_files` | no | false | Set to `true` to delete the remote path folder and all files in it **before** uploading. |
|
||||||
| `password` | no | | SSH password. If a password is set, `ssh_private_key` and `ssh_passphrase` is ignored. *(for @v1.2.4 and greater)* |
|
| `password` | no | | SSH password. If a password is set, `ssh_private_key` is ignored. *(for @v1.2.4 and greater)* |
|
||||||
| `rsyncArgs` | no | | Additional arguments for the `rsync` command. You can customize file synchronization behavior, such as excluding files or directories. Example: `--exclude=node_modules --exclude=.git --exclude=*.log`. *(for @v1.2.5 and greater)* |
|
| `rsyncArgs` | no | | Additional arguments for the `rsync` command. You can customize file synchronization behavior, such as excluding files or directories. Example: `--exclude=node_modules --exclude=.git --exclude=*.log`. *(for @v1.2.5 and greater)* |
|
||||||
| `ssh_passphrase` | no | | The passphrase for encrypted ssh private-key |
|
|
||||||
|
|
||||||
> ⚠️ **Warning:**
|
> ⚠️ **Warning:**
|
||||||
> Be careful when using `delete_remote_files`. This will **permanently delete** the remote path folder and all files in it **before** uploading.
|
> Be careful when using `delete_remote_files`. This will **permanently delete** the remote path folder and all files in it **before** uploading.
|
||||||
|
|
@ -45,7 +44,7 @@ jobs:
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Deploy to Server
|
- name: Deploy to Server
|
||||||
uses: wlixcc/SFTP-Deploy-Action@v1.2.6
|
uses: wlixcc/SFTP-Deploy-Action@v1.2.5
|
||||||
with:
|
with:
|
||||||
username: 'root'
|
username: 'root'
|
||||||
server: 'your server ip'
|
server: 'your server ip'
|
||||||
|
|
@ -71,7 +70,7 @@ jobs:
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Deploy with Exclude Patterns
|
- name: Deploy with Exclude Patterns
|
||||||
uses: wlixcc/SFTP-Deploy-Action@v1.2.6
|
uses: wlixcc/SFTP-Deploy-Action@v1.2.5
|
||||||
with:
|
with:
|
||||||
username: 'root'
|
username: 'root'
|
||||||
server: 'your server ip'
|
server: 'your server ip'
|
||||||
|
|
@ -98,7 +97,7 @@ jobs:
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Deploy with Password
|
- name: Deploy with Password
|
||||||
uses: wlixcc/SFTP-Deploy-Action@v1.2.6
|
uses: wlixcc/SFTP-Deploy-Action@v1.2.5
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.FTP_USERNAME }}
|
username: ${{ secrets.FTP_USERNAME }}
|
||||||
server: ${{ secrets.FTP_SERVER }}
|
server: ${{ secrets.FTP_SERVER }}
|
||||||
|
|
@ -109,31 +108,6 @@ jobs:
|
||||||
password: ${{ secrets.FTP_PASSWORD }}
|
password: ${{ secrets.FTP_PASSWORD }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### **🔹 Example with Encrypted Private Key Authentication**
|
|
||||||
```yaml
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy_job:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Deploy with encrypted private key
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Deploy with encrypted private key
|
|
||||||
uses: wlixcc/SFTP-Deploy-Action@v1.2.6
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.FTP_USERNAME }}
|
|
||||||
server: ${{ secrets.FTP_SERVER }}
|
|
||||||
port: ${{ secrets.FTP_PORT }}
|
|
||||||
local_path: './static/*'
|
|
||||||
remote_path: '/var/www/app'
|
|
||||||
sftp_only: true
|
|
||||||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
ssh_passphrase: ${{ secrets.SSH_PASSPHRASE }}
|
|
||||||
```
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🌐 **3. [Deploy React App Example](https://github.com/wlixcc/React-Deploy)**
|
## 🌐 **3. [Deploy React App Example](https://github.com/wlixcc/React-Deploy)**
|
||||||
|
|
@ -156,7 +130,7 @@ jobs:
|
||||||
run: yarn build
|
run: yarn build
|
||||||
|
|
||||||
- name: Deploy Build Folder
|
- name: Deploy Build Folder
|
||||||
uses: wlixcc/SFTP-Deploy-Action@v1.2.6
|
uses: wlixcc/SFTP-Deploy-Action@v1.2.5
|
||||||
with:
|
with:
|
||||||
username: 'root'
|
username: 'root'
|
||||||
server: '${{ secrets.SERVER_IP }}'
|
server: '${{ secrets.SERVER_IP }}'
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ inputs:
|
||||||
default: "22"
|
default: "22"
|
||||||
ssh_private_key:
|
ssh_private_key:
|
||||||
description: 'you can copy private_key from your *.pem file, keep format'
|
description: 'you can copy private_key from your *.pem file, keep format'
|
||||||
required: false
|
required: true
|
||||||
local_path:
|
local_path:
|
||||||
description: 'will put all file under this path'
|
description: 'will put all file under this path'
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -43,9 +43,7 @@ inputs:
|
||||||
If set, these arguments will be passed directly to the rsync command."
|
If set, these arguments will be passed directly to the rsync command."
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
ssh_passphrase:
|
|
||||||
description: "Passphrase for ssh encrypted private-key. If the private-key is not encrypted, this parameter is not required."
|
|
||||||
required: false
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
|
|
@ -62,7 +60,6 @@ runs:
|
||||||
- ${{ inputs.delete_remote_files }}
|
- ${{ inputs.delete_remote_files }}
|
||||||
- ${{ inputs.password }}
|
- ${{ inputs.password }}
|
||||||
- ${{ inputs.rsyncArgs }}
|
- ${{ inputs.rsyncArgs }}
|
||||||
- ${{ inputs.ssh_passphrase }}
|
|
||||||
|
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
|
|
|
||||||
|
|
@ -83,20 +83,6 @@ else
|
||||||
ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 mkdir -p $6
|
ssh -o StrictHostKeyChecking=no -p $3 -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2 mkdir -p $6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if passphrase is set, if yes decrypt the private key
|
|
||||||
if [ -n "${12:-}" ]; then
|
|
||||||
echo 'Use ssh-agent to decrypt private key with passphrase'
|
|
||||||
# start ssh agent
|
|
||||||
eval $(ssh-agent -s)
|
|
||||||
# use expect for ssh passphrase encryption
|
|
||||||
expect <<EOF
|
|
||||||
spawn ssh-add $TEMP_SSH_PRIVATE_KEY_FILE
|
|
||||||
expect "Enter passphrase"
|
|
||||||
send "${12}\r"
|
|
||||||
expect eof
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo 'SFTP Start'
|
echo 'SFTP Start'
|
||||||
# create a temporary file containing sftp commands
|
# create a temporary file containing sftp commands
|
||||||
printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE
|
printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE
|
||||||
|
|
@ -104,11 +90,4 @@ printf "%s" "put -r $5 $6" >$TEMP_SFTP_FILE
|
||||||
sftp -b $TEMP_SFTP_FILE -P $3 $8 -o StrictHostKeyChecking=no -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2
|
sftp -b $TEMP_SFTP_FILE -P $3 $8 -o StrictHostKeyChecking=no -i $TEMP_SSH_PRIVATE_KEY_FILE $1@$2
|
||||||
|
|
||||||
echo 'Deploy Success'
|
echo 'Deploy Success'
|
||||||
# if passphrase is set stop ssh-agent after sftp connection
|
|
||||||
if [ -n "${12:-}" ]; then
|
|
||||||
echo 'Clear keys from ssh-agent'
|
|
||||||
# delete all keys from RAM
|
|
||||||
ssh-add -D
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue