-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
87 lines (69 loc) · 1.98 KB
/
build.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
VERSION=$(git rev-parse --short HEAD)
if [ ! -d "../auth_proxy_builds" ]; then
mkdir "../auth_proxy_builds"
fi
if [ ! -d "../auth_proxy_builds/versions" ]; then
mkdir "../auth_proxy_builds/versions"
fi
FILENAME="powerbi_auth_proxy_build_$VERSION"
FILEPATH="../auth_proxy_builds/$FILENAME.zip"
TIMESTAMP=$(date +%F--%H-%M-%S)
VERSIONSDIR="../auth_proxy_builds/versions"
START_DIR=$(pwd)
if [ ! -f "$FILEPATH" ]; then
## remove the .env and protected files file if they exist
mkdir "../$TIMESTAMP"
for F in $(cat .gitignore)
do
if [ "$F" == "vendor" ]; then
echo "skipping vendor directory"
elif [ -f "$F" ]; then
echo "file - $F"
mkdir -p $(dirname "../$TIMESTAMP/$F")
mv "$F" "../$TIMESTAMP/$F"
elif [ -d "$F" ]; then
echo "dir - $F"
mkdir -p $(dirname "../$TIMESTAMP/$F")
mv "$F" "../$TIMESTAMP/$F"
if [ -f "../$TIMESTAMP/$F/.gitkeep" ]; then
mkdir "$F"
touch "$F/.gitkeep"
fi
fi
done
echo $VERSION > hash.txt
composer archive -f zip --dir="../auth_proxy_builds" --file="$FILENAME" --ignore-filters
cd $VERSIONSDIR
ln -s "../$FILENAME.zip" "build_$TIMESTAMP.zip"
cd ..
if [ -f current.zip ]; then
rm "current.zip"
fi
if [ -f hash.txt ]; then
rm "hash.txt"
fi
cp "$FILENAME.zip" "current.zip"
echo $VERSION > hash.txt
echo "syncing..."
bash "../S3_SYNC_AUTH_PROXY.sh"
cd "$START_DIR"
for F in $(cat .gitignore)
do
if [ -f "../$TIMESTAMP/$F" ]; then
cp "../$TIMESTAMP/$F" "$F"
elif [ -d "../$TIMESTAMP/$F" ]; then
if [ ! -d $(dirname "$F") ]; then
mkdir -p $(dirname "$F")
fi
cp -r "../$TIMESTAMP/$F" "$F"
fi
done
rm -r "../$TIMESTAMP"
# echo "adding back node_modules via npm..."
# cd "src/assets"
# npm i
echo "done."
else
echo "build is current"
fi