Deploy your nodejs or typescript app with PM2.
steps:
- uses: actions/checkout@v3
- name: Deploy app
uses: victorargento/pm2-deployment@main
with:
remote-path: "/deployment/api"
host: 12.34.56.78
username: ${{ secrets.prod-user }}
port: 2080
password: ${{ secrets.prod-password }}
pm2-id: "api"
The action does the following:
- Copies the repository contents to the remote server on the specified folder
- Runs
npm ci
- Runs
npm run build
(optional) - Runs
pm2 reload
the ecosystem.config.js - Runs
pm2 reset <id>
to set 0 the number of restarts
remote-path
- Where do you want to copy the files to?host
- _What's the host IP address?username
- What's the username that you're going to login intoport
- What's the port of SSH? (default:22
)password
- What's the password of the user?`` (Note: in the future SSH Keys will be supported)build
- Build your typescript apppm2-id
- What's the ID/Name of the PM2 application?
Note: I recommend to use ecosystem.config.js in your project, you can envs, interpreters, node args, num of instances and more options. Here there are more content about it.
Good Practices: Why do I use reload instead restart? Restart is a hard way to stop and start a web server.