-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (110 loc) · 3.76 KB
/
Copy pathdeploy.yml
File metadata and controls
129 lines (110 loc) · 3.76 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Deploy to VPS
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Detect changed paths
id: changes
uses: dorny/paths-filter@v4
with:
filters: |
api:
- 'api/**'
dashboard:
- 'dashboard/**'
landing:
- 'landing/**'
widget:
- 'widget/**'
- name: Setup SSH
if: |
steps.changes.outputs.api == 'true' ||
steps.changes.outputs.dashboard == 'true' ||
steps.changes.outputs.landing == 'true' ||
steps.changes.outputs.widget == 'true'
run: |
mkdir -p ~/.ssh
echo "${{ secrets.VPS_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
- name: Deploy api
if: steps.changes.outputs.api == 'true'
run: |
rsync -rvz --delete \
--exclude=".env" \
--exclude="node_modules" \
--exclude="public/uploads/" \
api/ \
${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }}:~/taphtml/api/
- name: Install api dependencies & restart PM2
if: steps.changes.outputs.api == 'true'
run: |
ssh ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} << 'EOF'
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
cd ~/taphtml/api
npm install --omit=dev
if pm2 describe taphtml > /dev/null 2>&1; then
pm2 restart taphtml
else
pm2 start npm --name "taphtml" -- start
fi
pm2 save
EOF
- name: Setup Node.js (dashboard)
if: steps.changes.outputs.dashboard == 'true'
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install dashboard dependencies
if: steps.changes.outputs.dashboard == 'true'
working-directory: dashboard
run: npm ci
- name: Build dashboard
if: steps.changes.outputs.dashboard == 'true'
working-directory: dashboard
env:
VITE_SERVER_URL: ${{ secrets.VITE_SERVER_URL }}
VITE_WIDGET_URL: ${{ secrets.VITE_WIDGET_URL }}
VITE_VAPID_PUBLIC_KEY: ${{ secrets.VITE_VAPID_PUBLIC_KEY }}
VITE_TELEGRAM_BOT_USERNAME: ${{ secrets.VITE_TELEGRAM_BOT_USERNAME }}
run: npm run build
- name: Deploy dashboard
if: steps.changes.outputs.dashboard == 'true'
run: |
rsync -rvz --delete \
dashboard/dist/ \
${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }}:~/taphtml/dashboard/
- name: Deploy landing
if: steps.changes.outputs.landing == 'true'
run: |
rsync -rvz --delete \
landing/ \
${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }}:~/taphtml/landing/
- name: Setup Node.js (widget)
if: steps.changes.outputs.widget == 'true'
uses: actions/setup-node@v6
with:
node-version: 24
- name: Install widget dependencies
if: steps.changes.outputs.widget == 'true'
working-directory: widget
run: npm ci
- name: Build widget
if: steps.changes.outputs.widget == 'true'
working-directory: widget
env:
VITE_SERVER_URL: ${{ secrets.VITE_SERVER_URL }}
run: npm run build
- name: Deploy widget
if: steps.changes.outputs.widget == 'true'
run: |
rsync -rvz --delete \
widget/dist/ \
${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }}:~/taphtml/widget/