forked from ktaicoder/hw-pet-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_deploy.sh
executable file
·51 lines (41 loc) · 984 Bytes
/
_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
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
set -e
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
cd "${SCRIPT_DIR}"
TEMP=_tmp
rm -rf ${TEMP}
mkdir -p ${TEMP}
TARGET_PROJ=huenit-serial
DEPLOY_SERVER=https://aicodiny.com
do_export() {
hwId=$1
$hwId/_purge.sh
$hwId/_export.sh
mv $hwId/main/out ${TEMP}/${hwId}
cd ${TEMP}
tar zcvf ${hwId}.tar.gz ${hwId}
cd ..
echo
echo "[${hwId}] Build successfully"
echo
}
do_export $TARGET_PROJ
do_deploy() {
hwId=$1
echo "start deploy ${hwId}.tar.gz"
curl -F "file=@$TEMP/${hwId}.tar.gz;filename=${hwId}.tar.gz" \
-F 'shiftSingleTopFolder=true' \
-H "x-dati-api-token: ${DATI_API_TOKEN}" \
$DEPLOY_SERVER/aimk-server/p/api/dati/extract/hw-iframe/${hwId}
echo
echo "[${hwId}] Deployed successfully"
echo
}
if [ -z "$DATI_API_TOKEN" ]; then
echo ""
echo "[error] Api token required for deployment"
exit 1
fi
do_deploy $TARGET_PROJ
echo "rm -rf ${TEMP}"
rm -rf ${TEMP}