All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 40s
55 lines
1.8 KiB
YAML
55 lines
1.8 KiB
YAML
name: Build and Deploy TenantApi
|
||
|
||
on:
|
||
push:
|
||
branches:
|
||
- dev
|
||
|
||
jobs:
|
||
build-and-deploy:
|
||
runs-on: host
|
||
steps:
|
||
- name: Checkout code
|
||
run: |
|
||
cd /opt/deploy/tenantapi || mkdir -p /opt/deploy/tenantapi
|
||
cd /opt/deploy/tenantapi
|
||
|
||
# 如果已有仓库就 pull,否则 clone
|
||
if [ -d ".git" ]; then
|
||
git fetch origin dev
|
||
git reset --hard origin/dev
|
||
git submodule update --init --recursive
|
||
else
|
||
git clone --branch dev ssh://git@git.laosankeji.com:2222/msumshk/TakeoutSaaS.TenantApi.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
|
||
fi
|
||
|
||
- name: Build on host
|
||
run: |
|
||
cd /opt/deploy/tenantapi
|
||
dotnet restore src/Api/TakeoutSaaS.TenantApi/TakeoutSaaS.TenantApi.csproj
|
||
dotnet publish src/Api/TakeoutSaaS.TenantApi/TakeoutSaaS.TenantApi.csproj -c Release -o /opt/deploy/tenantapi/publish --no-restore
|
||
|
||
- name: Build Docker image
|
||
run: |
|
||
cd /opt/deploy/tenantapi
|
||
docker build -t takeoutsaas-tenantapi:latest -f src/Api/TakeoutSaaS.TenantApi/Dockerfile .
|
||
|
||
- name: Deploy container
|
||
run: |
|
||
docker stop tenantapi || true
|
||
docker rm tenantapi || true
|
||
docker run -d \
|
||
--name tenantapi \
|
||
--restart unless-stopped \
|
||
-p 7903:7903 \
|
||
-e ASPNETCORE_ENVIRONMENT=Development \
|
||
takeoutsaas-tenantapi:latest
|
||
|
||
- name: Clean up old images
|
||
run: |
|
||
docker image prune -f
|