使用 CircleCI 通过 scp 部署 dist 文件夹时部署作业卡住

deploy job stuck when using CircleCI to deploy dist folder over scp

我使用 ci/cd 的第一步,并尝试为我的宠物项目设置 CircleCI。

我在 digitalocean 上有 VPS 服务器,希望在 build faze 之后,dist 文件夹的内容将通过 scp 上传到服务器。我的 config.yml 如下:

version: 2.1

executors:
  my-executor:
    docker:
      - image: circleci/node:12.9.1-browsers
    working_directory: ~/repo

jobs:
  build:
    executor: my-executor

    steps:
      - checkout

      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-
      - run: yarn install

      - save_cache:
          paths:
            - node_modules
            - ~/.npm
            - ~/.cache
          key: v1-dependencies-{{ checksum "package.json" }}

      - run: yarn build

  deploy:
    executor: my-executor

    steps:
      - run:
          name: Deploy Over SSH
          command: |
            scp -r dist/* $SERVER_USER_NAME@$SERVER_IP:/var/www/example.com/html

workflows:
  version: 2

  build-deploy:
    jobs:
      - build
      - deploy:
          requires:
            - build

build 工作完美,但 deploy 工作卡住了,我只看到这条消息:

#!/bin/bash -eo pipefail
scp -r dist/* $SERVER_USER_NAME@$SERVER_IP:/var/www/example.com/html
The authenticity of host '************ (************)' can't be established.
ECDSA key fingerprint is SHA256:Yu/i9AcPRAJtyT43QrQMdI3tSB3*************.

我已将私人 ssh 密钥添加到 circleci 并将 public 密钥添加到 authorized_keys

我哪里错了? 谢谢。

好的,我需要手动将我的主机添加到已知主机,如下所示:

- run:
    name: Add to known hosts
    command: ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts

不然问我要不要手动添加,卡住了