优化部署脚本并更新 .gitignore

- 修改 .gitignore,将 .idea 目录改为 .idea/**
- 在部署脚本中添加下载失败检查和 unzip 安装检查
- 优化部署脚本的错误处理和用户提示
This commit is contained in:
2025-03-13 20:03:16 +08:00
parent 8059df501e
commit 689d0e3f5d
3 changed files with 22 additions and 1 deletions

2
.gitignore vendored
View File

@@ -1,5 +1,5 @@
# Ignore IDE files
.idea/
.idea/**
!.idea/icon.png
.vscode/
*.suo

BIN
.idea/icon.png generated Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -18,6 +18,27 @@ trap cleanup EXIT
echo "开始下载最新构建产物..."
curl -L -o "$TEMP_DIR/artifact.zip" "$REPO_URL/-/jobs/artifacts/main/download?job=build"
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
echo "下载失败,请检查网络连接或重新尝试。"
exit 1
fi
# 检查 unzip 是否可用,不可用时自动安装
if ! command -v unzip &> /dev/null; then
echo "unzip 未安装,开始安装 ···"
if command -v apt-get &> /dev/null; then
sudo apt-get update
sudo apt-get install -y unzip
elif command -v yum &> /dev/null; then
sudo yum install -y unzip
else
echo "无法安装 unzip请手动安装。"
exit 1
fi
fi
echo "解压文件..."
unzip -q "$TEMP_DIR/artifact.zip" -d "$TEMP_DIR"