From 35ee9e119e0c10df1d9d4d716fffe38d8867654b Mon Sep 17 00:00:00 2001 From: yhl452493373 Date: Sat, 22 Nov 2025 00:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=B4=E6=98=8E=EF=BC=8C?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=9C=8D=E5=8A=A1=E7=AB=AF=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5docker=20hub=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/BuildServer.yml | 8 +++++++- README.md | 2 +- build-server.sh | 9 ++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/BuildServer.yml b/.github/workflows/BuildServer.yml index d8f6fff..bcdbc61 100644 --- a/.github/workflows/BuildServer.yml +++ b/.github/workflows/BuildServer.yml @@ -66,7 +66,13 @@ jobs: - name: 构建 Docker 镜像 run: | # 运行构建脚本 - ./build-server.sh + if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ]; then + echo "使用 secrets 中的 Docker Hub 用户名" + ./build-server.sh "${{ secrets.DOCKERHUB_USERNAME }}" + else + echo "使用默认 Docker Hub 用户名" + ./build-server.sh + fi - name: 获取镜像标签 id: exist-tag diff --git a/README.md b/README.md index 0ac2a45..7f804fb 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ + [build-launcher.sh](build-launcher.sh) 用于在非docker环境中调用docker镜像构建启动器 + [build.sh](build.sh) 是 [build-launcher.sh](build-launcher.sh) 和 [BuildLauncher.yml](.github/workflows/BuildLauncher.yml) 中调用的脚本 -+ [build-server.sh](build-server.sh) 用于构建服务端镜像,也是 [BuildServer.yml](.github/workflows/BuildServer.yml) 中调用的脚本 ++ [build-server.sh](build-server.sh) 用于构建服务端镜像,也是 [BuildServer.yml](.github/workflows/BuildServer.yml) 中调用的脚本,需要把里面的`yhl452493373`换成你自己的`Docker Hub`的用户名 + [bin](bin)目录下的[zip](bin/zip)和[unzip](bin/unzip)是ubuntu中使用的zip压缩和解压缩软件的二进制文件 ## [build-launcher.sh](build-launcher.sh) 参数说明 diff --git a/build-server.sh b/build-server.sh index 5251ad9..9d92a63 100644 --- a/build-server.sh +++ b/build-server.sh @@ -2,6 +2,12 @@ SPT_SERVER_REPOSITORY=sp-tarkov/server-csharp SPT_SERVER_BRANCH=develop +# 设置默认用户名,支持从参数传入 +DOCKER_USERNAME="yhl452493373" +if [ ! -z "$1" ]; then + DOCKER_USERNAME="$1" +fi + SPT_BUILD_TYPE=RELEASE #LOCAL, DEBUG, RELEASE, BLEEDING_EDGE, BLEEDING_EDGE_MODS SPT_VERSION=$(git ls-remote --tags "https://github.com/$SPT_SERVER_REPOSITORY.git" | awk -F'/' '{print $NF}' | grep -v '\^{}' | sort -V | tail -1) SPT_VERSION=$(echo $SPT_VERSION | cut -d'-' -f1) @@ -10,13 +16,14 @@ SPT_COMMIT_ID=${SPT_COMMIT_ID:0:8} CLIENT_VERSION=$(wget -qO- "https://raw.githubusercontent.com/$SPT_SERVER_REPOSITORY/refs/heads/$SPT_SERVER_BRANCH/Libraries/SPTarkov.Server.Assets/SPT_Data/configs/core.json" | jq -r '.compatibleTarkovVersion') DATE_TIME=$(date +%Y%m%d) +echo "Docker Hub 用户名: $DOCKER_USERNAME" echo "SPT服务端构建类型:$SPT_BUILD_TYPE" echo "SPT服务端版本:$SPT_VERSION" echo "SPT服务端提交ID:$SPT_COMMIT_ID" echo "适用客户端版本:$CLIENT_VERSION" echo "构建日期:$DATE_TIME" -IMAGE_TAG="yhl452493373/spt-server:$SPT_VERSION-$DATE_TIME-$SPT_COMMIT_ID" +IMAGE_TAG="$DOCKER_USERNAME/spt-server:$SPT_VERSION-$DATE_TIME-$SPT_COMMIT_ID" echo "开始构建镜像"