-
Notifications
You must be signed in to change notification settings - Fork 1
92 lines (68 loc) · 2.15 KB
/
Copy pathcd.yml
File metadata and controls
92 lines (68 loc) · 2.15 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# name: CD
# on:
# workflow_run:
# workflows: ["CI"]
# types:
# - completed
# jobs:
# deploy-core-api:
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
# runs-on: ubuntu-latest
# steps:
# - name: Deploy to EC2
# uses: appleboy/ssh-action@v1.0.3
# with:
# host: ${{ secrets.EC2_HOST }}
# username: ${{ secrets.EC2_USER }}
# key: ${{ secrets.EC2_SSH_KEY }}
# script: |
# cd ${{ secrets.EC2_APP_PATH }}
# git pull origin main
# corepack enable
# corepack prepare pnpm@latest --activate
# pnpm install --frozen-lockfile
# pnpm --filter core-api build:prod
# pm2 restart core-api
name: CD
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
set -e
cd ~/apps/noillin
echo "Pulling latest code..."
git pull origin main
echo "Enabling corepack..."
corepack enable
corepack prepare pnpm@latest --activate
echo "Installing dependencies..."
pnpm install --frozen-lockfile
echo "Building shared..."
pnpm --filter shared build
echo "Building core-api..."
pnpm --filter core-api build
echo "Building realtime..."
pnpm --filter realtime build
echo "Building worker..."
pnpm --filter worker build
echo "Building web..."
pnpm --filter web build
echo "Restarting PM2 services..."
pm2 reload ecosystem.config.js --update-env || pm2 start ecosystem.config.js
echo "Saving PM2..."
pm2 save
echo "Deployment completed successfully."