Skip to content

部署文件到远程服务器上,并且连接远程服务器

License

Notifications You must be signed in to change notification settings

nuonuonuonuoyan/scp-pushfile-ssh-remote

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configuration options

with 参数 是否必填 默认值 字段描述
user root 登录远程服务器的用户名.
host localhost 远程服务器的 ip 地址.
port 22 远程服务器的端口.
password 登录远程服务器的密码.
scp_key 公钥,从服务器 ~/.ssh/id_rsa 文件获取,需要添加到 github 项目的 Secrets.
source 上传的目录或文件.
target 服务器对应的项目目录.
exclude 上传的目录中需要排除的文件或子目录.
command 服务器终端命令行:当部署的项目为 node 项目时,可能需要一些后续操作,比如需要在服务器上启动项目,使用 pm2 开启进程守护等等操作,可以自行进行后续等操作

Recommended action configuration

使用示例(例如:.github/workflows/deploy.yml)

name: deploy

on:
  push:
    branches: [master]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: 📥 Checkout the repository
        uses: actions/checkout@v2

      - name: 📤 Upload files to the server and connect to the remote server
        uses: nuonuonuonuoyan/auto-deploy@v1
        with:
          user: ${{ secrets.USER }}
          host: ${{ secrets.HOST }}
          scp_key: ${{ secrets.SCP_KEY }}
          source: '/'
          target: '/home/tests'
          password: ${{ secrets.PASSWORD }}
          command: |
            cd /home/tests
            git pull
            echo `ls -a`

About

部署文件到远程服务器上,并且连接远程服务器

Resources

License

Stars

Watchers

Forks

Packages

No packages published