Skip to content

refactor(clicks): write the click row and the counter in one transaction #74

refactor(clicks): write the click row and the counter in one transaction

refactor(clicks): write the click row and the counter in one transaction #74

Workflow file for this run

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: '22'
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