-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (64 loc) · 2.32 KB
/
ga-redeploy.yml
File metadata and controls
73 lines (64 loc) · 2.32 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
name: 🔑 Redeploy DevTools - Production
on:
workflow_run:
workflows: ['🐳 Build Docker Image']
types: [completed]
branches: [master]
jobs:
deployment:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: 💽 Redeploy DevTools
runs-on: devtools.01edu.ai
environment: production
permissions: { packages: read, contents: read }
steps:
- name: 🔐 Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: 🐳 Pull latest Docker image
run: docker pull ghcr.io/${{ github.repository }}:latest
- name: 🛑 Stop existing container
run: |
if docker ps -q -f name=devtools-app; then
echo "Stopping existing devtools-app container..."
docker stop devtools-app
docker rm devtools-app
else
echo "No existing devtools-app container found"
fi
- name: 🧹 Clean up old images
run: |
docker image prune -f
- name: 🔄 Create network and volume if not exist
run: |
if ! docker network ls | grep -q devtools-network; then
docker network create devtools-network
fi
if ! docker volume ls | grep -q devtools-pictures; then
docker volume create devtools-pictures
fi
- name: 🚀 Deploy new container
run: |
echo "Deploying commit: ${{ github.sha }}"
docker run -d \
--name devtools-app \
--network devtools-network \
--env-file /root/devtools/.env.prod \
-e CI_COMMIT_SHA=${{ github.sha }} \
-p 8877:3021 \
-v /root/devtools/db:/app/db \
-v devtools-pictures:/app/.picture \
--restart unless-stopped \
ghcr.io/${{ github.repository }}:latest
- name: ✅ Verify deployment
run: |
echo "Waiting for container to be ready..."
sleep 10
# Check container status
if docker ps | grep -q devtools-app; then
echo "✅ Container is running"
docker logs --tail=20 devtools-app
else
echo "❌ Container failed to start"
docker logs devtools-app
exit 1
fi