Refactored pipeline to separate build and test, package and deploy promostion stages
This commit is contained in:
77
.drone.yml
77
.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
|
x-docker-auth: &docker-auth
|
||||||
DOCKER_AUTH_CONFIG: |
|
DOCKER_AUTH_CONFIG: |
|
||||||
{
|
{
|
||||||
@@ -39,4 +65,53 @@ steps:
|
|||||||
--context=.
|
--context=.
|
||||||
--dockerfile=Dockerfile
|
--dockerfile=Dockerfile
|
||||||
--destination=index.docker.io/khwezi/webapitest:latest
|
--destination=index.docker.io/khwezi/webapitest:latest
|
||||||
--destination=index.docker.io/khwezi/webapitest:${DRONE_BUILD_NUMBER}
|
--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
|
||||||
Reference in New Issue
Block a user