mirror of
https://github.com/ChenjxJames/SFTP-Deploy-Action.git
synced 2025-09-11 13:08:02 +08:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9289a89a12 | ||
|
4404f4759c | ||
|
28d6168ebf | ||
|
f19d10cf6b | ||
|
cf8d9e5b50 | ||
|
6ff9f12bc8 | ||
|
b2206dcb19 | ||
|
19ad014b34 | ||
|
1f1ab26f78 | ||
|
564673d595 | ||
|
7fd32bff94 | ||
|
610ec6e1c9 | ||
![]() |
f1b3556b75 | ||
![]() |
6b5c2a4271 |
97
README.md
97
README.md
@@ -4,37 +4,42 @@
|
|||||||
|
|
||||||
> 使用此`action`部署你的项目到服务器上,`仅支持密钥对连接`
|
> 使用此`action`部署你的项目到服务器上,`仅支持密钥对连接`
|
||||||
|
|
||||||
|
> [使用Github Action 部署项目到云服务器](https://zhuanlan.zhihu.com/p/107545396)
|
||||||
|
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
### `username`
|
### `username`
|
||||||
|
|
||||||
> **Required** sftp username.
|
**Required** sftp username.
|
||||||
|
|
||||||
### `server`
|
### `server`
|
||||||
|
|
||||||
> **Required** sftp server address.
|
**Required** sftp server address.
|
||||||
|
|
||||||
### `port`
|
### `port`
|
||||||
|
|
||||||
> sftp srever port , default `22`.
|
sftp srever port , default `22`
|
||||||
|
|
||||||
### `ssh_private_key`
|
### `ssh_private_key`
|
||||||
|
|
||||||
> **Required** you can copy private_key from your `ssh_private_key.pem file`, keep format, and save at`repo/settings/secrets`
|
**Required** you can copy private_key from your `ssh_private_key.pem file`, keep format, and save at`repo/settings/secrets`
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
### `local_path`
|
### `local_path`
|
||||||
|
|
||||||
> **Required** `local_path` of you project, if you want put single file:use path like `./myfile`, if you want put directory: use path like `./static/*`, it will put all files under `static` directory. Default to `./*`(will put all files in your repo).
|
**Required** `local_path` of you project, if you want put single file:use path like `./myfile`, if you want put directory: use path like `./static/*`, it will put all files under `static` directory. Default to `./*`(will put all files in your repo).
|
||||||
|
|
||||||
### `remote_path`
|
### `remote_path`
|
||||||
> **Required** remote_path
|
**Required** remote_path
|
||||||
|
|
||||||
### `args`
|
### `args`
|
||||||
> args of sftp cmd, E.g.`-o ConnectTimeout=5`
|
args of sftp cmd, E.g.`-o ConnectTimeout=5`
|
||||||
|
|
||||||
|
|
||||||
## Example usage
|
## Action Example
|
||||||
|
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
@@ -47,11 +52,81 @@
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: deploy file
|
- name: deploy file
|
||||||
uses: ./ # Uses an action in the root directory
|
uses: wlixcc/SFTP-Deploy-Action@v1.0
|
||||||
with:
|
with:
|
||||||
username: 'root'
|
username: 'root'
|
||||||
server: 'your server ip'
|
server: 'your server ip'
|
||||||
private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
local_path: './static/*'
|
local_path: './static/*'
|
||||||
remote_path: '/var/www/app' #make sure dir exist
|
remote_path: '/var/www/app'
|
||||||
args: '-o ConnectTimeout=5'
|
args: '-o ConnectTimeout=5'
|
||||||
|
|
||||||
|
## 1. [Deploy React App Example](https://github.com/wlixcc/React-Deploy)
|
||||||
|
|
||||||
|
> If you use nginx, all you need to do is upload the static files to the server after the project is built
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy_job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: build&deploy
|
||||||
|
steps:
|
||||||
|
# To use this repository's private action, you must check out the repository
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: yarn
|
||||||
|
- name: Build
|
||||||
|
run: yarn build
|
||||||
|
|
||||||
|
- name: deploy file to server
|
||||||
|
uses: wlixcc/SFTP-Deploy-Action@v1.0
|
||||||
|
with:
|
||||||
|
username: 'root'
|
||||||
|
server: '${{ secrets.SERVER_IP }}'
|
||||||
|
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
local_path: './build/*'
|
||||||
|
remote_path: '/var/www/react-app'
|
||||||
|
args: '-o ConnectTimeout=5'
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 2.Deploy Umi App Example (Ant Design Pro)
|
||||||
|
|
||||||
|
name: continuous deployment
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy_job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: build&deploy
|
||||||
|
steps:
|
||||||
|
# To use this repository's private action, you must check out the repository
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install umi
|
||||||
|
run: yarn global add umi
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: yarn
|
||||||
|
- name: Build
|
||||||
|
run: yarn build
|
||||||
|
|
||||||
|
- name: deploy file to server
|
||||||
|
uses: wlixcc/SFTP-Deploy-Action@v1.0
|
||||||
|
with:
|
||||||
|
username: 'root'
|
||||||
|
server: '${{ secrets.SERVER_IP }}'
|
||||||
|
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
local_path: './dist/*'
|
||||||
|
remote_path: '/var/www/umiapp'
|
||||||
|
args: '-o ConnectTimeout=5'
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# action.yml
|
# action.yml
|
||||||
name: 'SFTP Deploy'
|
name: 'SFTP Deploy No SSH'
|
||||||
description: 'Deploy file to your server use sftp & ssh private key'
|
description: 'Deploy file to your server use sftp & ssh private key'
|
||||||
inputs:
|
inputs:
|
||||||
username:
|
username:
|
||||||
|
@@ -13,7 +13,6 @@ printf "%s" "$4" >$TEMP_SSH_PRIVATE_KEY_FILE
|
|||||||
chmod 600 $TEMP_SSH_PRIVATE_KEY_FILE
|
chmod 600 $TEMP_SSH_PRIVATE_KEY_FILE
|
||||||
|
|
||||||
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
|
||||||
#-o StrictHostKeyChecking=no avoid Host key verification failed.
|
#-o StrictHostKeyChecking=no avoid Host key verification failed.
|
||||||
|
BIN
resource/reactExample.jpg
Normal file
BIN
resource/reactExample.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 123 KiB |
BIN
resource/secret.jpg
Normal file
BIN
resource/secret.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
BIN
resource/umiExample.jpg
Normal file
BIN
resource/umiExample.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 94 KiB |
Reference in New Issue
Block a user