0

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

我在 digitalocean 上安装了 VPS 服务器,并希望在buildfaze 之后,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 并将公钥添加到authorized_keys

我哪里错了?谢谢你。

4

1 回答 1

0

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

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

否则,它会询问我是否需要手动添加它并卡在它上面。

于 2020-08-01T14:37:18.777 回答