首页 > 解决方案 > 无法使用 GitHub Actions/Gitlab CI/CD 通过 SCP 部署(超时)

问题描述

我有一个 React.js 应用程序,我正在尝试使用 Github Actions 进行自动部署。我遵循了 Github 在其操作页面上的一些示例。构建看起来正确,我将构建文件夹作为工件输出,但我试图通过 SCP 将构建文件夹发送到我的远程服务器,但看起来我的跑步者没有互联网连接,因为我收到超时。

我在我的机器上尝试了相同的 scp 命令,它运行良好。

到目前为止,我的 yaml 是这样的:

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request 
# events but only for the master branch
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel 
jobs:
  # This workflow contains a single job called "build" 
  build:
    # The type of runner that the job will run on
    runs-on: [ubuntu-latest]

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2

    # Runs a set of commands using the runners shell
    #sudo apt-get update && sudo apt-get install -y lftp && sudo rm -rf /var/lib/apt/lists/*

    - name: Run a multi-line script
      run: |
        npm install
        CI=false npm run-script build

    - name: List output files
      run: ls

    - name: Create security file
      run: |
        touch securityfile
        echo -e "${{ secrets.PRIVATE_KEY }}" >securityfile
        chmod 600 securityfile

    - name: Deploy via SCP
      run: scp -o StrictHostKeyChecking=no -v -i securityfile -r build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/www

我也尝试在 GitLab 中做一个管道,但得到了相同的结果(超时)。

标签: linuxgithubgitlabscpgithub-actions

解决方案


推荐阅读