Repository navigation
135 lines (120 loc) · 4.31 KB
/
Copy pathdev-deploy.yaml
File metadata and controls
135 lines (120 loc) · 4.31 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Dev Deploy
on:
push:
branches: [dev]
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
member: ${{ steps.filter.outputs.member }}
collage: ${{ steps.filter.outputs.collage }}
archive: ${{ steps.filter.outputs.archive }}
swagger: ${{ steps.filter.outputs.swagger }}
nginx: ${{ steps.filter.outputs.nginx }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
shared: &shared
- 'framey-common/**'
- 'framey-web/**'
- 'framey-monitoring/**'
- 'build.gradle'
- 'settings.gradle'
- 'gradle/**'
member:
- *shared
- 'framey-application/member-service/**'
collage:
- *shared
- 'framey-application/collage-service/**'
archive:
- *shared
- 'framey-application/archive-service/**'
swagger:
- 'framey-infrastructure/swagger-dev/**'
nginx:
- 'framey-infrastructure/nginx/**'
deploy:
needs: detect-changes
runs-on: ubuntu-latest
if: |
needs.detect-changes.outputs.member == 'true' ||
needs.detect-changes.outputs.collage == 'true' ||
needs.detect-changes.outputs.archive == 'true' ||
needs.detect-changes.outputs.swagger == 'true' ||
needs.detect-changes.outputs.nginx == 'true'
steps:
- name: Build target services list
id: targets
run: |
SERVICES=""
if [ "${{ needs.detect-changes.outputs.member }}" == "true" ]; then
SERVICES="$SERVICES member-dev"
fi
if [ "${{ needs.detect-changes.outputs.collage }}" == "true" ]; then
SERVICES="$SERVICES collage-dev"
fi
if [ "${{ needs.detect-changes.outputs.archive }}" == "true" ]; then
SERVICES="$SERVICES archive-dev"
fi
if [ "${{ needs.detect-changes.outputs.swagger }}" == "true" ]; then
SERVICES="$SERVICES swagger-dev"
fi
if [ "${{ needs.detect-changes.outputs.nginx }}" == "true" ]; then
SERVICES="$SERVICES nginx"
fi
echo "services=$SERVICES" >> $GITHUB_OUTPUT
- name: Deploy to DEV EC2
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEV_EC2_HOST }}
username: ${{ secrets.DEV_EC2_USER }}
key: ${{ secrets.DEV_EC2_SSH_KEY }}
script: |
cd /home/ec2-user/Framey-Server
git pull origin dev
export DEV_DB_URL="${{ secrets.DEV_DB_URL }}"
export DEV_DB_USER="${{ secrets.DEV_DB_USER }}"
export DEV_DB_PASSWORD="${{ secrets.DEV_DB_PASSWORD }}"
docker compose \
-f framey-infrastructure/docker/dev/docker-compose.dev.yaml \
up -d --build --no-deps ${{ steps.targets.outputs.services }}
- name: Health Check
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEV_EC2_HOST }}
username: ${{ secrets.DEV_EC2_USER }}
key: ${{ secrets.DEV_EC2_SSH_KEY }}
script: |
sleep 30
SERVICES="${{ steps.targets.outputs.services }}"
check_health() {
local name=$1
local port=$2
for i in $(seq 1 20); do
if docker exec framey-dev-${name} \
wget -qO- http://localhost:${port}/actuator/health 2>/dev/null \
| grep -q '"status":"UP"'; then
echo "✅ ${name} is healthy"
return 0
fi
sleep 5
done
echo "❌ ${name} health check failed"
docker logs --tail=50 framey-dev-${name}
return 1
}
FAILED=0
if echo "$SERVICES" | grep -q "member-dev"; then
check_health "member" 8081 || FAILED=1
fi
if echo "$SERVICES" | grep -q "collage-dev"; then
check_health "collage" 8082 || FAILED=1
fi
if echo "$SERVICES" | grep -q "archive-dev"; then
check_health "archive" 8083 || FAILED=1
fi
exit $FAILED