diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..11c0ba3 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,29 @@ +name: Docker Image CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build the Docker image + run: | + docker login --username=springhgui0127 registry.cn-hangzhou.aliyuncs.com --password=${{ secrets.PASSWORD }} + version=$(grep "" src/Directory.Build.props | awk -F'[<>]' '{print $3}') + echo $version + tag=registry.cn-hangzhou.aliyuncs.com/hgui/opentask:$version-$(date +%s) + echo $tag + docker build . --file Dockerfile --tag $tag + docker push $tag + + + + diff --git a/Dockerfile b/Dockerfile index a2437bb..cccd3b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ ARG BUILD_CONFIGURATION=Release RUN dotnet publish "OpenTask.WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false # ui -FROM docker.m.daocloud.io/node:20.12.0 AS ui +FROM registry.cn-hangzhou.aliyuncs.com/hgui/node:20.12.0 AS ui WORKDIR /app COPY ["ui/vite-opentask", "./"] RUN rm -rf package-lock.json node_modules diff --git a/publish.sh b/publish.sh index 74bbe80..0c6aa19 100644 --- a/publish.sh +++ b/publish.sh @@ -7,16 +7,17 @@ fi # 读取文件内容,并使用grep和awk提取Version的值 version=$(grep "" src/Directory.Build.props | awk -F'[<>]' '{print $3}') -appName=opentask +appName=registry.cn-hangzhou.aliyuncs.com/hgui/opentask:$version # 输出Version的值 echo "Version: $version" -docker build . -t $appName:$version +docker build . -t $appName if [ $? -ne 0 ]; then echo "docker image build fail 😭😭😭" else echo "docker image build success 🎉🎉🎉" fi +docker push $appName read exit 1 \ No newline at end of file