PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 28, 2022

[FIXED] How can I deploy a node.js app to a private server after a successful Travis build/test?

 September 28, 2022     continuous-deployment, github, node.js, travis-ci     No comments   

Issue

This is the pipeline I have in mind for my node.js app:

write code at dev machine -> commit to github -> Travis builds and tests -> on success: deploy to private server

I'm looking for tool(s) to accomplish the last part.

For instance, some tool that would be notifed by Travis and would pull the code from the github to my private server (and deploy the app in that way).


Solution

According to travis-ci documentation

You can easily deploy to your own server the way you would deploy from your local machine by adding a custom after_success step.

You may choose the Script provider instead, as it provides easier flexibility with conditional deployment.

FTP

env:
  global:
    - "FTP_USER=user"
    - "FTP_PASSWORD=password"
after_success:
    "curl --ftp-create-dirs -T uploadfilename -u $FTP_USER:$FTP_PASSWORD ftp://sitename.com/directory/myfile"

The env variables FTP_USER and FTP_PASSWORD can also be encrypted.

See curl(1) for more details on how to use cURL as an FTP client.

or Git

after_success:
  - eval "$(ssh-agent -s)" #start the ssh agent
  - chmod 600 .travis/deploy_key.pem # this key should have push access
  - ssh-add .travis/deploy_key.pem
  - git remote add deploy DEPLOY_REPO_URI_GOES_HERE
  - git push deploy

See “How can I encrypt files that include sensitive data?” if you don’t want to commit the private key unencrypted to your repository.



Answered By - gevorg
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing