-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (52 loc) · 1.68 KB
/
Copy pathcd.yml
File metadata and controls
65 lines (52 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# .github/workflows/cd.yml
# Prometheus Banking Platform - Continuous Deployment Pipeline
# Deploys to VPS after successful CI on main branch
name: CD
on:
workflow_run:
workflows: ["CI"]
types: [completed]
branches: [main]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/prometheus-app
jobs:
deploy:
name: Deploy to VPS
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.29.0'
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 'v3.13.0'
- name: Set up kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
- name: Verify cluster connection
run: kubectl cluster-info
- name: Deploy infrastructure (if changed)
run: |
kubectl apply -k k8s/overlays/production/
- name: Update application image
run: |
# Update image tag in deployment
kubectl set image deployment/prometheus-app \
prometheus-app=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
-n prometheus \
--record || echo "Deployment not found - skipping"
- name: Wait for rollout
run: |
kubectl rollout status deployment/prometheus-app -n prometheus --timeout=300s || echo "Rollout check skipped"
- name: Verify deployment
run: |
kubectl get pods -n prometheus
kubectl get services -n prometheus