【问题标题】:Github Actions - copy files to VPSGithub Actions - 将文件复制到 VPS
【发布时间】:2021-09-25 11:37:31
【问题描述】:

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

Github worflow,当将文件推送到 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...?

【问题讨论】:

    标签: github ssh copy github-actions


    【解决方案1】:

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

    GitHub Action 用于通过 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 否:这个答案的重点是说明您不需要 Makefile,因为有一个 GitHub Action 将为您执行 scp(复制)。
    猜你喜欢
    • 2021-10-18
    • 2020-04-18
    • 2022-01-02
    • 1970-01-01
    • 2020-01-14
    • 2022-08-08
    • 2021-10-03
    • 2021-01-15
    • 2021-05-20
    相关资源
    最近更新 更多