I have simple ec2 server in which I have added GitHub actions for CI/CD all the things are working fine but issue is when I change something in existing end points or do anything in existing code on server my code is not reflecting I can see there is green tick on my commit and code is pushed to my server but its not reflecting. And If I do pm2 restart index.js
manually on server then every things is working fine. Also If I create new route or something then it's reflecting I think there is some issue in my workflow file ? But I am not getting it why it's happening.
name: Ci/Cd Pipeline
on:
push:
branches: [ "staging" ]
pull_request:
branches: [ "staging" ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [18.x]
steps:
- name: cleanup #https://github.com/actions/checkout/issues/21
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
- uses: actions/checkout@v3
- run: sudo npm i
- run: sudo pm2 kill -a
- run: sudo pm2 start index.js