ci: 新增 MiniApi gitea 部署工作流
All checks were successful
Build and Deploy MiniApi / build-and-deploy (push) Successful in 19s
All checks were successful
Build and Deploy MiniApi / build-and-deploy (push) Successful in 19s
This commit is contained in:
54
.gitea/workflows/deploy.yml
Normal file
54
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,54 @@
|
||||
name: Build and Deploy MiniApi
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: host
|
||||
steps:
|
||||
- name: Checkout code
|
||||
run: |
|
||||
cd /opt/deploy/miniapi || mkdir -p /opt/deploy/miniapi
|
||||
cd /opt/deploy/miniapi
|
||||
|
||||
# 如果已有仓库就同步 main,否则执行 clone
|
||||
if [ -d ".git" ]; then
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
git submodule update --init --recursive
|
||||
else
|
||||
git clone --branch main ssh://git@git.laosankeji.com:2222/msumshk/TakeoutSaaS.C-Side-Mini-Program-API.git .
|
||||
git submodule init
|
||||
git config submodule.TakeoutSaaS.BuildingBlocks.url ssh://git@git.laosankeji.com:2222/msumshk/TakeoutSaaS.BuildingBlocks.git
|
||||
git config submodule.TakeoutSaaS.Docs.url ssh://git@git.laosankeji.com:2222/msumshk/TakeoutSaaS.Docs.git
|
||||
git submodule update --init --recursive
|
||||
fi
|
||||
|
||||
- name: Build on host
|
||||
run: |
|
||||
cd /opt/deploy/miniapi
|
||||
dotnet restore TakeoutSaaS.sln
|
||||
dotnet publish src/Api/TakeoutSaaS.MiniApi/TakeoutSaaS.MiniApi.csproj -c Release -o /opt/deploy/miniapi/publish --no-restore
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
cd /opt/deploy/miniapi
|
||||
docker build -t takeoutsaas-miniapi:latest -f src/Api/TakeoutSaaS.MiniApi/Dockerfile .
|
||||
|
||||
- name: Deploy container
|
||||
run: |
|
||||
docker stop miniapi || true
|
||||
docker rm miniapi || true
|
||||
docker run -d \
|
||||
--name miniapi \
|
||||
--restart unless-stopped \
|
||||
-p 7803:7803 \
|
||||
-e ASPNETCORE_ENVIRONMENT=Development \
|
||||
takeoutsaas-miniapi:latest
|
||||
|
||||
- name: Clean up old images
|
||||
run: |
|
||||
docker image prune -f
|
||||
Reference in New Issue
Block a user