-
Notifications
You must be signed in to change notification settings - Fork 2
56 lines (47 loc) · 1.46 KB
/
Copy pathdeploy.yml
File metadata and controls
56 lines (47 loc) · 1.46 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
name: Deploy Frontend
on:
push:
branches:
- main
jobs:
deploy:
runs-on: self-hosted
environment: production
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Copy .env
run: cp "${{ secrets.DEPLOY_ENV_PATH }}" .env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
NEXT_PUBLIC_API_URL=$(grep -E '^NEXT_PUBLIC_API_URL=' .env | cut -d= -f2-)
docker build \
--build-arg NEXT_PUBLIC_API_URL="${NEXT_PUBLIC_API_URL}" \
-t gsmsv-frontend:latest \
-t gsmsv-frontend:${{ github.sha }} \
.
- name: Deploy container
run: |
docker compose down --remove-orphans || true
docker compose up -d
- name: Verify frontend status
run: |
MAX=12
for i in $(seq 1 $MAX); do
echo "Waiting for frontend... ($i/$MAX)"
if docker compose ps frontend | grep -q "Up"; then
echo "frontend is Up."
docker compose ps frontend
exit 0
fi
if [ "$i" -eq "$MAX" ]; then
echo "Timeout: frontend did not become healthy within $((MAX * 5)) seconds."
docker compose logs frontend --tail=50
exit 1
fi
sleep 5
done
- name: Remove dangling images
run: docker image prune -f