-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathdeploy.sh
executable file
·39 lines (30 loc) · 1.18 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
if [ -z "$(git status --porcelain)" ]; then
echo ">>> Working directory is clean"
TMP_LOC=/tmp/jdl-studio
DEPLOY_BRANCH=gh-pages
SRC_BRANCH=src
/bin/rm -rf dist || exit
/bin/rm -rf $TMP_LOC || exit
echo ">> Building app"
npm run build || exit
echo ">> Move build assets to temp folder"
mkdir --parents $TMP_LOC || exit
mv dist/* $TMP_LOC || exit
echo ">> Checkout and clean $DEPLOY_BRANCH branch"
git fetch && git checkout $DEPLOY_BRANCH || exit
find -mindepth 1 -depth -print0 | grep -vEzZ '(.github(/|$)|node_modules(/|$)|.tmp(/|$)|.git(/|$)|/\.gitignore$|/\LICENSE.txt$|/\README.md$)' | xargs -0 rm -rvf || exit
echo ">> Move app form temp & publish to GitHub"
mv $TMP_LOC/* . || exit
now=$(date)
git config user.name github-actions || exit
git config user.email [email protected] || exit
git add --all || exit
git commit -am "Updated app on $now" --allow-empty || exit
git push origin $DEPLOY_BRANCH --force || exit
echo ">> $now: Published changes to GitHub"
git checkout $SRC_BRANCH
else
echo ">> Working directory is not clean. Commit changes and try again!"
exit
fi