Restructured pipeline to better use ssh for deployment

This commit is contained in:
Khwezi
2025-10-18 14:19:02 +02:00
parent 31d4c4af55
commit 1d4199c450

View File

@@ -4,17 +4,9 @@ type: kubernetes
name: build name: build
clone: clone:
disable: true disable: false
steps: steps:
- 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: dotnet restore - name: dotnet restore
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
@@ -30,7 +22,6 @@ steps:
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
- dotnet test --configuration Release - dotnet test --configuration Release
--- ---
kind: pipeline kind: pipeline
type: kubernetes type: kubernetes
@@ -43,14 +34,6 @@ clone:
disable: true disable: true
steps: steps:
- 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: dotnet publish - name: dotnet publish
image: mcr.microsoft.com/dotnet/sdk:8.0 image: mcr.microsoft.com/dotnet/sdk:8.0
commands: commands:
@@ -70,7 +53,6 @@ steps:
from_secret: registry-password from_secret: registry-password
dockerfile: Dockerfile dockerfile: Dockerfile
context: ./SampleApi/bin/Release/net8.0/publish/ context: ./SampleApi/bin/Release/net8.0/publish/
--- ---
kind: pipeline kind: pipeline
type: kubernetes type: kubernetes
@@ -93,10 +75,7 @@ steps:
from_secret: host-password from_secret: host-password
port: 22 port: 22
script: script:
- | - set -euo pipefail
set -euo pipefail - echo "Applying Kubernetes manifest via SSH..."
echo "Applying Kubernetes manifest via SSH..." - cat ./manifests/deploy.yml | kubectl apply -f -
ssh -o StrictHostKeyChecking=no $DRONE_REMOTE_USER@lead.mngoma.lab 'kubectl apply -f -' <<'EOF' - echo "Manifest applied successfully."
$(cat ./manifests/deploy.yml)
EOF
echo "Manifest applied successfully."