feat(lite): deploy script (#6413)

This commit is contained in:
Pierre Donias 2022-09-12 09:27:27 +02:00 committed by Julien Fontanet
parent aebb47ad38
commit 6b60cfce4d
2 changed files with 68 additions and 0 deletions

View File

@ -6,6 +6,7 @@
"build": "run-p type-check build-only", "build": "run-p type-check build-only",
"preview": "vite preview --port 4173", "preview": "vite preview --port 4173",
"build-only": "vite build", "build-only": "vite build",
"deploy": "./scripts/deploy.sh",
"type-check": "vue-tsc --noEmit", "type-check": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
}, },

View File

@ -0,0 +1,67 @@
#!/bin/bash
set -euo pipefail
if [ $# -ne 1 ]
then
echo "Usage: ./deploy.sh <LDAP username>"
exit 1
fi
USERNAME=$1
DIST="dist"
BASE="https://lite.xen-orchestra.com/dist"
SERVER="www-xo.gpn.vates.fr"
echo "Building XO Lite"
(cd ../.. && yarn)
yarn build-only --base="$BASE"
echo "Deploying XO Lite from $DIST"
echo "\"use strict\";
(function () {
const d = document;
function js(file) {
const s = d.createElement(\"script\");
s.defer = \"defer\";
s.type = \"module\";
s.crossOrigin = \"anonymous\";
s.src = file;
d.body.appendChild(s);
}
$(
for filename in "$DIST"/assets/*.js; do
echo " js(\"$BASE/assets/$(basename $filename)\");"
done
)
function css(file) {
const s = d.createElement(\"link\");
s.rel = \"stylesheet\";
s.href = file;
d.head.appendChild(s);
}
$(
for filename in "$DIST"/assets/*.css; do
echo " css(\"$BASE/assets/$(basename $filename)\");"
done
)
})();" > "$DIST/index.js"
rsync \
-r --delete --delete-excluded --exclude=index.html \
"$DIST"/ \
"$USERNAME@$SERVER:xo-lite"
echo "XO Lite files sent to server"
echo "→ Connect to the server using:"
echo -e "\tssh $USERNAME@$SERVER"
echo "→ Log in as xo-lite using"
echo -e "\tsudo -su xo-lite"
echo "→ Then run the following command to move the files to the \`latest\` folder:"
echo -e "\trsync -r --delete --exclude=index.html /home/$USERNAME/xo-lite/ /home/xo-lite/public/latest"