neotix-matheuscampos of Neotix
1/21/2020 - 8:37 PM

CI deploy circleci with git and ssh - NODE JS API

CI deploy with ssh key fingerprint in circleci plataform.

version: 2
jobs:
  deploy:
    docker:
      - image: circleci/node:12
        environment:
          NODE_ENV: development
    steps:
      - add_ssh_keys:
          fingerprints:
            - "Your fingerprint"
      - checkout
      - run: 
          name: Deploy Master Branch
          command: |
            ssh -o StrictHostKeyChecking=no user@host_ip bash << EOF
              cd /var/www/directory
              git pull
              npm i
              pm2 restart your-api-process-name
              exit
              exit
            EOF

workflows:
  version: 2
  just-deploy:
    jobs:
      - deploy:
          filters:
            branches:
              only: master