87 lines
1.9 KiB
YAML
87 lines
1.9 KiB
YAML
---
|
|
kind: pipeline
|
|
type: kubernetes
|
|
name: build
|
|
|
|
clone:
|
|
disable: false
|
|
|
|
steps:
|
|
- name: dotnet restore
|
|
image: mcr.microsoft.com/dotnet/sdk:8.0
|
|
commands:
|
|
- dotnet restore
|
|
|
|
- name: dotnet build
|
|
image: mcr.microsoft.com/dotnet/sdk:8.0
|
|
commands:
|
|
- dotnet build --configuration Release
|
|
- ls ./SampleApi/bin/Release/net8.0/
|
|
|
|
- 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
|
|
|
|
clone:
|
|
disable: true
|
|
|
|
steps:
|
|
- name: dotnet publish
|
|
image: mcr.microsoft.com/dotnet/sdk:8.0
|
|
commands:
|
|
- dotnet publish --configuration Release
|
|
- ls ./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
|
|
registry: registry-server.registry.svc.cluster.local:5000
|
|
insecure: 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
|
|
|
|
clone:
|
|
disable: true
|
|
|
|
steps:
|
|
- name: deploy via SSH
|
|
image: appleboy/drone-ssh
|
|
settings:
|
|
host: lead.mngoma.lab
|
|
username:
|
|
from_secret: host-username
|
|
password:
|
|
from_secret: host-password
|
|
port: 22
|
|
script:
|
|
- set -euo pipefail
|
|
- echo "Applying Kubernetes manifest via SSH..."
|
|
# Apply the manifest remotely via kubectl on the host
|
|
- ssh -o StrictHostKeyChecking=no $DRONE_REMOTE_USER@lead.mngoma.lab 'kubectl apply -f -' <<'EOF'
|
|
$(cat ./manifests/deploy.yml)
|
|
EOF
|
|
- echo "Manifest applied successfully."
|