Sunday 28 May 2017

How to auto deploy on ec2 using gitlab runners?

I want to auto deploy node.js project on gitlab.

Currently I'm using below configuration on .gitlab-ci.yml

deploy_to_dev_aws:
  only:
    - development
  script:
    - echo "$EC2_SSH_KEY" >> "key.pem"
    - chmod 600 key.pem
    - ssh -T -i key.pem -o StrictHostKeyChecking=no ubuntu@$EC2_HOST_IP <<EOF
    - cd ~/projects
    - rm myproject
    - git checkout git://myprojectpath
    - cd myproject
    - pm2 delete all
    - pm2 start app.js
    - logout
    - EOF
  stage: build

Is this right way, as I'm log in into ec2 and performing all operations?

What are other ways to do the same?



via JagsSparrow

No comments:

Post a Comment