我使用ci/cd的第一步,并尝试为我的宠物项目设置CircleCI。
我在digitalocean上有VPS服务器,希望在build
失败后,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*************.
我为circleci添加了专用ssh密钥,为authorized_keys
添加了公钥
我哪里错了?非常感谢。
好的,我需要手动将我的主机添加到已知的主机中,如下所示:
- run:
name: Add to known hosts
command: ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts
否则,它会问我是否需要手动添加它,并被卡住了