-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (28 loc) · 911 Bytes
/
nodejs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Node.js CI/CD on Amazon Linux
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Deploy to AWS EC2
uses: tcooperma/scp-action@main
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "./" # This now correctly points to the current directory
target: "/var/www/your_project_directory"
- name: Restart PM2 application
uses: tcooperma/ssh-action@main
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /var/www/your_project_directory
pm2 reload all # This command restarts your application