Skip to content

Commit 1b3b554

Browse files
committed
adding ci-cd
1 parent 4a99bd9 commit 1b3b554

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/ci-cd.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: piplines for second brain node js backends
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: 📥 Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: 🔧 Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
21+
- name: 📦 Install dependencies
22+
run: npm install
23+
24+
- name: 🏗️ Build the project
25+
run: npm run build
26+
27+
- name: 🔐 Setup SSH key
28+
run: |
29+
mkdir -p ~/.ssh
30+
echo "${{ secrets.VM_SSH_KEY }}" > ~/.ssh/id_rsa
31+
chmod 600 ~/.ssh/id_rsa
32+
ssh-keyscan -H ${{ secrets.VM_HOST }} >> ~/.ssh/known_hosts
33+
34+
- name: 🚀 Deploy and run on VM
35+
run: |
36+
ssh ubuntu@${{ secrets.VM_HOST }} "
37+
cd /home/ubuntu/second-brain &&
38+
git pull origin main &&
39+
npm install &&
40+
npm run build &&
41+
pm2 restart myapp || pm2 start dist/index.js --name myapp
42+
"

0 commit comments

Comments
 (0)