-
Notifications
You must be signed in to change notification settings - Fork 33
/
fetch_config_files.sh
52 lines (46 loc) · 1.88 KB
/
fetch_config_files.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
#!/bin/sh
SCHEMA_FILE="sql-review-schema.yaml"
PROD_TEMPLATE="sql-review.prod.yaml"
DEV_TEMPLATE="sql-review.dev.yaml"
LOCALIZATION_FOLDER="./locales"
mkdir -p "$LOCALIZATION_FOLDER/sql-review"
mkdir -p "$LOCALIZATION_FOLDER/subscription"
CONSOLE_VERSION_FOR_PRICING="main"
CONSOLE_VERSION_FOR_SQL_REVIEW="main"
URL="https://raw.githubusercontent.com/bytebase/bytebase"
input=(
# SQL review files
"$URL/$CONSOLE_VERSION_FOR_SQL_REVIEW/frontend/src/types/$SCHEMA_FILE"
"$URL/$CONSOLE_VERSION_FOR_SQL_REVIEW/backend/plugin/advisor/config/$PROD_TEMPLATE"
"$URL/$CONSOLE_VERSION_FOR_SQL_REVIEW/backend/plugin/advisor/config/$DEV_TEMPLATE"
"$URL/$CONSOLE_VERSION_FOR_SQL_REVIEW/frontend/src/locales/sql-review/en-US.json"
"$URL/$CONSOLE_VERSION_FOR_SQL_REVIEW/frontend/src/locales/sql-review/zh-CN.json"
# subscription files
"$URL/$CONSOLE_VERSION_FOR_PRICING/frontend/src/types/plan.yaml"
"$URL/$CONSOLE_VERSION_FOR_PRICING/frontend/src/locales/subscription/en-US.json"
"$URL/$CONSOLE_VERSION_FOR_PRICING/frontend/src/locales/subscription/zh-CN.json"
)
output=(
# SQL review files
"./common/$SCHEMA_FILE"
"./common/$PROD_TEMPLATE"
"./common/$DEV_TEMPLATE"
"$LOCALIZATION_FOLDER/sql-review/en.json"
"$LOCALIZATION_FOLDER/sql-review/zh.json"
# subscription files
"./common/plan.yaml"
"$LOCALIZATION_FOLDER/subscription/en.json"
"$LOCALIZATION_FOLDER/subscription/zh.json"
)
for (( i=0; i<${#input[@]}; i++ ));
do
echo "Start to fetch the SQL Review config file from ${input[$i]} to ${output[$i]}."
response=$(curl -w "%{http_code}" -o ${output[$i]} ${input[$i]} --retry 3 --retry-all-errors)
http_code=$(tail -n1 <<< "$response")
if [ $http_code != 200 ]
then
echo "Failed to download the SQL Review config file from ${input[$i]}."
exit 1
fi
done
echo "Successfully updated the SQL Review config file."