Github Actions - 将文件复制到 VPS

4

我想在一个小型VPS提供商上解决这个问题:

Github工作流,在将文件推送到GitHub时,“GH工作流”会复制php文件到实时VPS服务器。

我该如何复制它们?

.github/workflows/vps-deploy-prod.yml:

name: vps-deploy-prod

on:
  push:
    branches:
      - master

jobs:

  build: 'VPS Run Deploy'
  runs-on: ubuntu-latest    
  steps:
    - name: 'Checkout'
      uses: action/checkout@master
    - name: 'Deploy'
      run: make vps-run-deploy

Makefile文件:
##### VPS specific target
vps-run-deploy:

?? copy files via ssh scp...?
1个回答

4

您可以考虑使用 GitHub 操作 appleboy/scp-action

GitHub 操作 通过 SSH 复制文件和工件。

这是该项目中的示例:renatomh/gobarber-backend/.github/workflows/main.yml

      # Copy the repository to the directory on the server/VPS used for the application
      - name: Copy dist to VPS
        uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          port: ${{ secrets.SSH_PORT }}
          key: ${{ secrets.SSH_KEY }}
          # Selecting all folders except "node_modules"
          source: ".,!node_modules"
          # The path is based on the directory where the user logged into the server starts
          target: "~/app/gobarber-backend"

可以用Makefile解决吗? - gabor
@gabor 不需要Makefile的重点是,因为有一个GitHub Action可以为您执行scp(复制)操作。 - VonC

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接