-
Notifications
You must be signed in to change notification settings - Fork 4
46 lines (34 loc) · 1.21 KB
/
ec2-deploy.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
36
37
38
39
40
41
42
43
44
45
46
name: Deploy to EC2 with Prisma Migrations and Cleanup
on:
push:
branches:
- master # Specify your deployment branch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Add SSH Key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_KEY }}
- name: Deploy to EC2, Clean Up Old Migrations, and Run Prisma Migrations
run: |
ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.EC2_IP }} << 'EOF'
cd /home/ubuntu/Campus-Chatter/backend # Change this to your project path on EC2
# Stash any local changes
git stash
# Pull the latest changes from master
git pull origin master
# Remove old migration files
rm -rf prisma/migrations
# Install any new dependencies
npm install
# Apply Prisma migrations using deploy for production (instead of dev)
npx prisma migrate deploy --force
# Compile TypeScript
tsc -b
# Restart your backend service using PM2
pm2 restart dist/index.js
EOF