2

I recently deployed my GitHub project in aws using Amazon Linux 2 AMI.

I installed npm, MongoDB, node and cloned the Github repo into the new instance that I created by sshing into it.
I am running the server with the forever package of npm.

Now, I made some changes in the code and pushed it to my Github repo but it's not being reflected in my project when I try to access it from outside.

So, how to redeploy it so that I see my changes when I access it from outside world?
I found this video which shows how to redeploy but it's not feasible in my case to do it.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Abhishek
  • 113
  • 3
  • 12

2 Answers2

2

Now, I made some changes in the code and pushed it to my Github repo but it's not being reflected in my project

Pushing to GitHub is one step.
But you still need to ssh to your execution environment (aws), and pull from GitHub in order to get the latest.
Then your npm application would have a chance to display your changes.

As an alternative to forever restart, you also can use PM2, as recommended here.


Another option would be to add a GitHub Action, like one of the deployment actions, in order to automate that step.
AWS proposes dedicated GitHub actions.

Full example: "Github Actions for web apps" from Luke Boyle.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

From what I'm able to figure out you need to do the following steps:

  1. Do a git pull after logging into your server via ssh.
  2. cd toTheFolder where your git repo is located
  3. git pull origin yourBranchName
  4. forever restart or forever restartall should restart your server and your changes should reflect there.

And as VonC suggested you should go for PM2 instead but for now you can continue with forever. PM2 is very similar to forever but with a lot more features available.

Black Mamba
  • 13,632
  • 6
  • 82
  • 105