source: Klonkt/deploy/post-receive@ 0c2228a

main
Last change on this file since 0c2228a was 605642d, checked in by Robin <robin@…>, 4 months ago

Add deploy hook + claim bd issue prutfolio-src-0tg

  • deploy/post-receive: working hook (uses --work-tree, pm2 reload)
  • bd: prutfolio-src-0tg in_progress
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[605642d]1#!/bin/bash
2# PrutFolio deploy-hook — werkt zoals logboek-hook.
3# Bare repo is single source of truth.
4# /srv/prutfolio is de working tree — gevuld via "git --work-tree=..."
5# (geen .git submap erin), zelfde patroon als logboek->celine.
6set -e
7
8DEPLOY=/srv/prutfolio
9GIT_DIR=/home/roboburr/git-repos/prutfolio.git
10
11while read oldrev newrev refname ; do
12 [ "$refname" != "refs/heads/main" ] && continue
13
14 echo ">>> Deploying $newrev to $DEPLOY"
15
16 # 1. Heel zelden — als een eerdere bug git-internals los in $DEPLOY
17 # heeft gedumpt (HEAD/objects/refs op root), eenmalig opruimen
18 # zodat dit een echte working tree wordt.
19 if [ -f "$DEPLOY/HEAD" ] && [ -d "$DEPLOY/objects" ] && [ ! -d "$DEPLOY/.git" ]; then
20 echo " cleanup: stale bare-init artifacts in $DEPLOY"
21 for f in branches config description FETCH_HEAD HEAD hooks info objects refs ORIG_HEAD; do
22 rm -rf "$DEPLOY/$f" 2>/dev/null || true
23 done
24 fi
25
26 # 2. Force-checkout van bare-repo state naar working tree.
27 git --git-dir="$GIT_DIR" --work-tree="$DEPLOY" checkout -f main
28
29 # 3. npm install alleen als package-lock.json wijzigde.
30 if [ -n "$oldrev" ] && [ "$oldrev" != "0000000000000000000000000000000000000000" ]; then
31 if git --git-dir="$GIT_DIR" diff --name-only "$oldrev" "$newrev" | grep -q "^package-lock.json$"; then
32 echo ">>> package-lock.json changed — npm ci --production"
33 cd "$DEPLOY" && npm ci --production
34 fi
35 fi
36
37 # 4. pm2 reload — proces heet "prutcms" (legacy naam)
38 pm2 reload prutcms 2>/dev/null || pm2 reload prutfolio 2>/dev/null || true
39
40 echo ">>> Done. App-files in $DEPLOY ongemoeid (.env, node_modules, storage)."
41done
Note: See TracBrowser for help on using the repository browser.