38 lines
932 B
Bash
Executable File
38 lines
932 B
Bash
Executable File
#!/bin/bash
|
|
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
|
|
|
|
DST_DIR=/var/www/dbg
|
|
KMP_FILE=kornerr-ver-browser
|
|
KMP_FILE_EXT=js
|
|
MAIN_BRANCH=main
|
|
REPO_DIR=/home/kornerr/repo-ru
|
|
REPO_URL=https://github.com/kornerr/ru
|
|
|
|
# Clone since the directory does not exist
|
|
if [ ! -d "$REPO_DIR" ]; then
|
|
git clone $REPO_URL $REPO_DIR
|
|
fi
|
|
|
|
# Get the latest changes
|
|
cd $REPO_DIR
|
|
git checkout -f $MAIN_BRANCH
|
|
git fetch --all
|
|
|
|
# Find out the latest commit in the whole repo
|
|
#git branch -av --sort=-committerdate
|
|
#git branch -av --sort=-committerdate | tr -s ' ' | head -n1
|
|
cmt=`git branch -av --sort=-committerdate | tr -s ' ' | head -n1 | cut -d' ' -f3`
|
|
echo "Latest commit: $cmt"
|
|
|
|
# Switch to the latest commit
|
|
git checkout -f $cmt
|
|
|
|
# Copy dist
|
|
mkdir -p $DST_DIR
|
|
rm -fR $DST_DIR/*
|
|
cp -R dist/* $DST_DIR
|
|
|
|
# Rename kornerr-ver-browser.js to work around caching
|
|
KMP_UUID=$KMP_FILE-`uuidgen`.$KMP_FILE_EXT
|
|
mv $DST_DIR/$KMP_FILE.$KMP_FILE_EXT $DST_DIR/$KMP_UUID
|