-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (77 loc) · 3.45 KB
/
deploy.yml
File metadata and controls
92 lines (77 loc) · 3.45 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: Deploy MSK Paste
on:
push:
branches:
- main
permissions:
contents: read
jobs:
deploy:
name: Build & Deploy
runs-on: ubuntu-latest
steps:
# ── 1. Checkout ──────────────────────────────────────────
- name: ⬇️ Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
# ── 2. Node.js ───────────────────────────────────────────
- name: ⚙️ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: npm
# ── 3. Install ───────────────────────────────────────────
- name: 📦 Install dependencies
run: npm ci
# ── 4. Build ─────────────────────────────────────────────
# NEXT_PUBLIC_* must be available at build time.
# DB_* are dummies so the build can complete – real values
# live at runtime in /opt/msk-paste/.env on the server.
- name: 🏗️ Build
env:
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
DB_HOST: build-dummy
DB_USER: build-dummy
DB_PASSWORD: build-dummy
DB_NAME: build-dummy
IP_HASH_SECRET: build-dummy-secret-do-not-use
run: npm run build
# ── 5. Deploy via SCP ────────────────────────────────────
- name: 🚀 Deploy to server
uses: appleboy/scp-action@v1.0.0
with:
host: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.FTP_PORT }}
source: ".next/,public/,migrations/,messages/,scripts/,src/,package.json,package-lock.json,next.config.ts,tsconfig.json,msk-paste.service"
target: /opt/msk-paste/
# ── 6. Server setup ──────────────────────────────────────
- name: 🛠️ Install production deps, run migrations, restart
uses: appleboy/ssh-action@v1.2.5
with:
host: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.FTP_PORT }}
script: |
cd /opt/msk-paste
# Stop the service before touching node_modules
systemctl stop msk-paste || true
# Clean install
rm -rf /opt/msk-paste/node_modules
npm ci --omit=dev
npm install --no-save tsx
# Run migrations
npm run migrate
# Fix permissions
chown -R musiker15:musiker15 /opt/msk-paste/
chmod -R u+w /opt/msk-paste/.next/
chmod 600 /opt/msk-paste/.env
# Reload service file if it changed
cp /opt/msk-paste/msk-paste.service /etc/systemd/system/msk-paste.service
systemctl daemon-reload
# Restart
systemctl restart msk-paste
systemctl status msk-paste --no-pager