Skip to content

Commit

Permalink
fix: 创建云函数时不写入 commmit id
Browse files Browse the repository at this point in the history
  • Loading branch information
chen310 committed Mar 22, 2022
1 parent af24b8c commit 4cd5188
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions serverless/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
config_file="config.json"
old_config_file="config.old.json"
example_config_file="config.example.json"

sed -i "s/commitId/$SHA/g" $example_config_file

# 复制模板文件为配置文件
cp config.example.json config.json
cp $example_config_file $config_file

url=$(python serverless/geturl.py)
if [[ $url == *ERROR* ]]; then
# 未部署函数
Expand All @@ -19,23 +26,18 @@ else
echo "正在解压"
unzip -o code.zip -d code/ >>/dev/null
rm -f code.zip
config_file="config.json"
old_config_file="config.old.json"
example_config_file="config.example.json"
sed -i "s/commitId/$SHA/g" $example_config_file
# 复制模板文件为配置文件
cp $example_config_file $config_file

if [ -e "code/config.json" ]; then
# 备份配置文件
mv code/config.json $old_config_file
# 将旧配置文件中的数据转移到新配置文件中
python updateconfig.py $example_config_file $old_config_file $config_file
if [ $? -ne 0 ]; then
echo "配置文件复制错误,请检查 config.json 文件是否填写正确"
echo "配置文件更新出错,请到云函数检查 config.json 文件是否填写正确"
echo -e "\033[1;31m部署失败 \033[0m"
exit 1
fi
echo "已加载配置文件"
echo "已更新配置文件"
export DEPLOY_TYPE="update"
else
echo "配置文件不存在,请检查 FUNCTION_NAME 填写是否正确,避免覆盖其他函数"
Expand Down

0 comments on commit 4cd5188

Please sign in to comment.