From 1128e2a484a9ed994b9ebe127373a44e5e372f54 Mon Sep 17 00:00:00 2001 From: xiaoliutral Date: Fri, 20 Mar 2026 15:29:29 +0800 Subject: [PATCH 1/3] Add CI/CD pipeline configuration for deployment --- .github/workflows/master.yml | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/master.yml diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 0000000..84a5b0f --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,41 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - master # 监视的分支 + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build to Server + uses: appleboy/ssh-action@v0.1.5 + with: + host: ${{ secrets.SSH_BUILD_HOST }} + username: ${{ secrets.SSH_USERNAME }} + password: ${{ secrets.SSH_PASSWORD }} + script: | + mkdir -p /data/projects + cd /data/projects + git clone git@github.com:xiaoliutral/SimpleAdmin.Api.git + cd SimpleAdmin.Api + git pull origin master + docker build -t admin_api:latest -f src/SimpleAdmin.Api/Dockerfile . + # 标记镜像 + docker tag admin_api:latest registry.nanafa.com/admin_api:latest + # 推送镜像 + docker push registry.nanafa.com/admin_api:latest + - name: Deploy to Server + uses: appleboy/ssh-action@v0.1.5 + with: + host: ${{ secrets.SSH_MANAGER_HOST }} + username: ${{ secrets.SSH_USERNAME }} + password: ${{ secrets.SSH_PASSWORD }} + script: | + cd /data + docker stack deploy -c api.yml api # yml没变化不会更新 + docker service update --force --image registry.nanafa.com/admin_api:latest api_admin # 一定要和service name一致 From 9e5f9381851e093e5064cb2f6fbd74342b2faef7 Mon Sep 17 00:00:00 2001 From: xiaoliutral Date: Fri, 20 Mar 2026 15:37:14 +0800 Subject: [PATCH 2/3] Update master.yml --- .github/workflows/master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 84a5b0f..57c1c02 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -24,7 +24,7 @@ jobs: git clone git@github.com:xiaoliutral/SimpleAdmin.Api.git cd SimpleAdmin.Api git pull origin master - docker build -t admin_api:latest -f src/SimpleAdmin.Api/Dockerfile . + docker build -t admin_api:latest -f src/Dockerfile . # 标记镜像 docker tag admin_api:latest registry.nanafa.com/admin_api:latest # 推送镜像 From 2572d1a20216f69d0db30dc288ec72d892d35a74 Mon Sep 17 00:00:00 2001 From: xiaoliutral Date: Fri, 20 Mar 2026 15:40:53 +0800 Subject: [PATCH 3/3] Update Dockerfile path in CI workflow --- .github/workflows/master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 57c1c02..84a5b0f 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -24,7 +24,7 @@ jobs: git clone git@github.com:xiaoliutral/SimpleAdmin.Api.git cd SimpleAdmin.Api git pull origin master - docker build -t admin_api:latest -f src/Dockerfile . + docker build -t admin_api:latest -f src/SimpleAdmin.Api/Dockerfile . # 标记镜像 docker tag admin_api:latest registry.nanafa.com/admin_api:latest # 推送镜像