deployment-dcdn/assets/webhook.sh

19 lines
594 B
Bash

#!/bin/bash
hook_origin=$1
repo_name=$(ls /var/www/repositories/ | grep -v '^cms')
cd /var/www/repositories/$repo_name
echo "Trigger : ${hook_origin}"
if [[ "$hook_origin" == "git" ]]; then
git pull origin prod
fi
jq '.scripts |= with_entries(.value |= gsub("\\bnuxt \\b"; "./node_modules/nuxt/bin/nuxt.mjs "))' package.json > temp.json && mv temp.json package.json
node --max-old-space-size=250 `which npm` install -y
node --max-old-space-size=250 `which npm` run generate --prerender
rm -r /var/www/html/public
cp -r "/var/www/repositories/${repo_name}/.output/public" /var/www/html