-
Notifications
You must be signed in to change notification settings - Fork 2
87 lines (73 loc) · 2.34 KB
/
frontend-deploy.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Frontend Deploy Pipeline
on:
push:
branches: ['main']
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: [self-hosted, linux, x64, frontend]
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Ensure buildx cache directory
run: mkdir -p /tmp/.buildx-cache
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: leonardomeireles55/quality-lab-pro-front-end:latest
cache-from: type=registry,ref=leonardomeireles55/quality-lab-pro-front-end:latest
cache-to: type=inline,mode=min
deploy:
needs: build
runs-on: [self-hosted, linux, x64, frontend]
environment: Production
steps:
- uses: actions/checkout@v4
- name: Deploy application
run: |
docker compose pull
docker compose up -d
- name: Deployment notification
run: echo "✅ Deployment completed"
health-check:
runs-on: [self-hosted, linux, x64, backend]
needs: deploy
timeout-minutes: 5
steps:
- name: Health check with timeout and retry
run: |
max_attempts=12
attempt=1
while [ $attempt -le $max_attempts ]; do
if curl -sSf https://lab-spec.systems/api/health-check; then
echo "✅ Service is healthy!"
exit 0
fi
echo "Attempt $attempt/$max_attempts - Service not healthy yet..."
sleep 15
attempt=$((attempt + 1))
done
echo "Health check failed after $max_attempts attempts"
exit 1
- name: Final status
if: success()
run: echo "🚀 Application is running successfully in production"