-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (56 loc) · 1.87 KB
/
ci-cd.yml
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
66
67
68
name: CI/CD Pipeline
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker images
run: |
docker-compose -f docker-compose.yml build
docker-compose -f docker-compose.yml push
- name: Deploy to Docker Compose
run: |
docker-compose down
docker-compose up -d
- name: Wait for services to start
run: sleep 30
- name: Check Prometheus
run: |
curl -sf http://localhost:9090/metrics || exit 1
- name: Check Node Exporter
run: |
curl -sf http://localhost:9100/metrics || exit 1
- name: Load environment variables
run: source .env
- name: Check Grafana
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" -u $GF_SECURITY_ADMIN_USER:$GF_SECURITY_ADMIN_PASSWORD http://localhost:3000)
echo "HTTP Response Code: $response"
if [ "$response" -ne 200 ]; then
echo "Grafana not accessible"
exit 1
fi
- name: Check Prometheus targets
run: |
response=$(curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets | length')
if [ "$response" -lt 1 ]; then
echo "No active targets found in Prometheus"
exit 1
fi
- name: Check Grafana Dashboard #being adqssyxe0dkaoa the uid of CPU dashboard out of the box
run: |
response=$(curl -s http://localhost:3000/api/dashboards/uid/adqssyxe0dkaoa -u $GF_SECURITY_ADMIN_USER:$GF_SECURITY_ADMIN_PASSWORD)
if [[ $response != *"cpu"* ]]; then
echo "CPU dashboard not found"
exit 1
fi