-
-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (82 loc) · 3.85 KB
/
Copy pathdeploy.yml
File metadata and controls
97 lines (82 loc) · 3.85 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
name: Deploy MSK Shortener
on:
push:
branches:
- main
# The code graph is documentation about the repository, it is never shipped.
# A commit that only refreshes it has nothing to deploy. Note that this only
# skips the run when every changed path matches: a commit touching both the
# graph and the app still deploys.
paths-ignore:
- 'graphify-out/**'
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: '24'
cache: npm
# ── 3. Install ───────────────────────────────────────────
- name: 📦 Install dependencies
run: npm ci
# ── 4. Build ─────────────────────────────────────────────
# NEXT_PUBLIC_* must be available at build time.
# DB_* sind Dummies, damit der Build durchläuft.
# Echte Werte stehen runtime in /opt/msk-shortener/.env auf dem 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-shortener.service"
target: /opt/msk-shortener/
# ── 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-shortener
# Stop the service before touching node_modules
systemctl stop msk-shortener || true
# Clean node_modules for a fresh install
rm -rf /opt/msk-shortener/node_modules
# Install production deps + tsx (for migrations)
npm ci --omit=dev
npm install --no-save tsx
# Fix permissions for service user
chown -R musiker15:musiker15 /opt/msk-shortener/
chmod -R u+w /opt/msk-shortener/.next/
chmod 600 /opt/msk-shortener/.env
# Reload service file if changed
cp /opt/msk-shortener/msk-shortener.service /etc/systemd/system/msk-shortener.service
systemctl daemon-reload
# Restart the service
systemctl restart msk-shortener
systemctl status msk-shortener --no-pager