From 02d1539a87b9556c7f44ef8eafac0156b7eadd2a Mon Sep 17 00:00:00 2001 From: Khwezi Date: Sun, 12 Oct 2025 14:43:23 +0200 Subject: [PATCH] Light refactor --- .drone.yml | 132 +++++++++++++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 65 deletions(-) diff --git a/.drone.yml b/.drone.yml index 963626f..6c4f493 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,36 +7,35 @@ clone: disable: true steps: -# git clone code base -- name: git clone - image: drone/git - commands: - - git clone http://gitea-server.gitea.svc.cluster.local:3000/mngomalab/sampleapi.git . - - git checkout $DRONE_COMMIT + - name: git clone + image: drone/git + environment: + REPO_URL: http://gitea-server.gitea.svc.cluster.local:3000/mngomalab/sampleapi.git + commands: + - git clone $REPO_URL . + - git checkout $DRONE_COMMIT -# dotnet restore -- name: dotnet restore - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet restore + - name: dotnet restore + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet restore -# dotnet build -- name: dotnet build - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet build --configuration Release - - ls ./SampleApi/bin/Release/net8.0/ + - name: dotnet build + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet build --configuration Release + - ls ./SampleApi/bin/Release/net8.0/ -# dotnet test -- name: dotnet test - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet test --configuration Release + - name: dotnet test + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet test --configuration Release --- kind: pipeline type: kubernetes name: package + depends_on: - build @@ -44,39 +43,37 @@ clone: disable: true steps: -# git clone code base -- name: git clone - image: drone/git - settings: - skip_verify: true - commands: - - git clone http://gitea-server.gitea.svc.cluster.local:3000/mngomalab/sampleapi.git . - - git checkout $DRONE_COMMIT + - name: git clone + image: drone/git + environment: + REPO_URL: http://gitea-server.gitea.svc.cluster.local:3000/mngomalab/sampleapi.git + commands: + - git clone $REPO_URL . + - git checkout $DRONE_COMMIT -# dotnet publish -- name: dotnet publish - image: mcr.microsoft.com/dotnet/sdk:8.0 - commands: - - dotnet publish --configuration Release - - ls ./SampleApi/bin/Release/net8.0/publish/ + - name: dotnet publish + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - dotnet publish --configuration Release + - ls ./SampleApi/bin/Release/net8.0/publish/ -# build and push docker image to in-cluster registry -- name: docker build and push - image: plugins/docker - settings: - repo: registry-server.registry.svc.cluster.local:5000/experiments/sampleapi - auto_tag: true - username: - from_secret: registry-username - password: - from_secret: registry-password - dockerfile: Dockerfile - context: ./SampleApi/bin/Release/net8.0/publish/ + - name: docker build and push + image: plugins/docker + settings: + repo: registry-server.registry.svc.cluster.local:5000/sampleapi + auto_tag: true + username: + from_secret: registry-username + password: + from_secret: registry-password + dockerfile: Dockerfile + context: ./SampleApi/bin/Release/net8.0/publish/ --- kind: pipeline type: kubernetes name: deploy + depends_on: - package @@ -84,21 +81,26 @@ clone: disable: true steps: -# git clone code base -- name: git clone - image: drone/git - settings: - skip_verify: true - commands: - - git clone http://gitea-server.gitea.svc.cluster.local:3000/mngomalab/sampleapi.git . - - git checkout $DRONE_COMMIT + - name: git clone + image: drone/git + environment: + REPO_URL: http://gitea-server.gitea.svc.cluster.local:3000/mngomalab/sampleapi.git + commands: + - git clone $REPO_URL . + - git checkout $DRONE_COMMIT -- name: deploy - image: danielgormly/drone-plugin-kube:0.0.1 - settings: - template: ./manifests/deploy.yml - ca: - from_secret: kube_ca_cert - server: https://lead:6443 - token: - from_secret: k8s-token + - name: ensure namespace + image: bitnami/kubectl:latest + commands: + - kubectl create namespace sampleapi --dry-run=client -o yaml | kubectl apply -f - + + - name: deploy + image: danielgormly/drone-plugin-kube:0.0.1 + settings: + template: ./manifests/deploy.yml + namespace: sampleapi + ca: + from_secret: kube_ca_cert + server: https://lead:6443 + token: + from_secret: k8s-token