使用gitlab-ci部署到digitalocean

时间:2020-04-21 12:47:20

标签: gitlab devops gitlab-ci digital-ocean gitlab-ci-runner

我正在尝试使用gitlab ci将我的nodejs项目部署到数字海洋,但工作一直失败。这是我的gitlab-ci.yml

image: node:12

cache:
  paths:
    - node_modules/

stages:
  - deploy

before_script:
  # Check for ssh-agent + rsync and install if not present
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y  )'
  - 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
  - eval $(ssh-agent -s)
  # Inject the remote's private key
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
  - mkdir -p ~/.ssh
  - chmod 700 ~/.ssh
  # Append keyscan output into known hosts
  - ssh-keyscan $SERVER_IP >> ~/.ssh/known_hosts
  - chmod 644 ~/.ssh/known_hosts
  - npm install
  - npm run build

deploy:
  stage: deploy
  script:
    - rsync -avuz --exclude=".*" $CI_PROJECT_DIR $SERVER_USER@$SERVER_IP:~
    - ssh $SERVER_USER@$SERVER_IP '. /etc/profile; pm2 reload all'
  only:
    - develop

这是我工作中的错误

enter image description here

我可能做错了什么?请我需要帮助

0 个答案:

没有答案
相关问题