From 3e590eed2c4d6bfb7cd24b4284db1425e37f164a Mon Sep 17 00:00:00 2001 From: khwezi Date: Sun, 8 Mar 2026 12:34:17 +0200 Subject: [PATCH] Refactored pipeline to separate build and test, package and deploy promostion stages --- .drone.yml | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 08d05e5..e996788 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,3 +1,29 @@ +--- +kind: pipeline +type: docker +name: build and test + +clone: + disable: true + +steps: + - name: checkout + image: alpine/git + commands: + - git clone https://gitea.khongisa.co.za/MngomaLab/webapitest.git . + - git checkout ${DRONE_COMMIT} + + - name: dotnet build + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet build --configuration Release + + - name: dotnet test + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet test --configuration Release + +--- x-docker-auth: &docker-auth DOCKER_AUTH_CONFIG: | { @@ -39,4 +65,53 @@ steps: --context=. --dockerfile=Dockerfile --destination=index.docker.io/khwezi/webapitest:latest - --destination=index.docker.io/khwezi/webapitest:${DRONE_BUILD_NUMBER} \ No newline at end of file + --destination=index.docker.io/khwezi/webapitest:${DRONE_BUILD_NUMBER} + +--- +kind: pipeline +type: docker +name: deploy + +clone: + disable: true + +steps: + - name: uat + image: appleboy/drone-ssh + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_user + key: + from_secret: ssh_key + script: + - docker pull khwezi/webapitest:latest + - docker stop webapitest || true + - docker rm webapitest || true + - docker run -d --name webapitest -p 4000:80 khwezi/webapitest:latest + when: + event: + - promote + target: + - uat + + - name: prod + image: appleboy/drone-ssh + settings: + host: + from_secret: ssh_host + username: + from_secret: ssh_user + key: + from_secret: ssh_key + script: + - docker pull khwezi/webapitest:latest + - docker stop webapi || true + - docker rm webapi || true + - docker run -d --name webapi -p 4001:80 khwezi/webapitest:latest + when: + event: + - promote + target: + - prod \ No newline at end of file -- 2.47.3