Use this action to deploy your files to a server using
SSH Private Key
使用此
action
部署你的项目到服务器上,中文介绍链接:使用Github Action 部署项目到云服务器
⚠️ Warning:
Be careful when usingdelete_remote_files
. This will permanently delete the remote path folder and all files in it before uploading.
on: [push]
jobs:
deploy_job:
runs-on: ubuntu-latest
name: Deploy Files
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deploy to Server
uses: wlixcc/[email protected]
with:
username: 'root'
server: 'your server ip'
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
local_path: './static/*'
remote_path: '/var/www/app'
sftpArgs: '-o ConnectTimeout=5'
on: [push]
jobs:
deploy_job:
runs-on: ubuntu-latest
name: Deploy with rsync exclude
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deploy with Exclude Patterns
uses: wlixcc/[email protected]
with:
username: 'root'
server: 'your server ip'
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
local_path: './'
remote_path: '/var/www/app'
rsyncArgs: '--exclude=node_modules --exclude=.git --exclude=*.log'
sftpArgs: '-o ConnectTimeout=5'
on: [push]
jobs:
deploy_job:
runs-on: ubuntu-latest
name: Deploy with Password
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deploy with Password
uses: wlixcc/[email protected]
with:
username: ${{ secrets.FTP_USERNAME }}
server: ${{ secrets.FTP_SERVER }}
port: ${{ secrets.FTP_PORT }}
local_path: './static/*'
remote_path: '/var/www/app'
sftp_only: true
password: ${{ secrets.FTP_PASSWORD }}
on: [push]
jobs:
deploy_job:
runs-on: ubuntu-latest
name: Build & Deploy React App
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Dependencies
run: yarn
- name: Build
run: yarn build
- name: Deploy Build Folder
uses: wlixcc/[email protected]
with:
username: 'root'
server: '${{ secrets.SERVER_IP }}'
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
local_path: './build/*'
remote_path: '/var/www/react-app'
rsyncArgs: '--exclude=*.map'
sftpArgs: '-o ConnectTimeout=5'
If you use the Ed25519 algorithm to generate an SSH key pair:
ssh-keygen -t ed25519 -C "[email protected]"
The last line of the private key must remain a blank line when adding it to Repository Secrets.
If you remove it, you might encounter an invalid format
error.