forked from Giveth/impact-graph
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (116 loc) · 5.17 KB
/
staging-deploy-only.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
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
name: staging-deploy-only
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: SSH and Redeploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd QAcc-BE
git reset --hard origin/staging
git checkout staging
git pull origin staging
docker image prune -a --force
docker compose pull
rollout-deploy-1:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: SSH and Redeploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd QAcc-BE
## Update each backend service one by one
## First Deployment
docker compose down qacc-be-graph-ql1
docker compose down qacc-be-job
docker compose up --force-recreate -d qacc-be-graph-ql1
docker compose up --force-recreate -d qacc-be-job
# Wait for qacc-be-graph-ql1 to be healthy (timeout after 5 minutes)
echo "Waiting for qacc-be-graph-ql1 to become healthy..."
timeout 300 bash -c 'until [ "$(docker inspect --format="{{json .State.Health.Status}}" qacc-be-graph-ql1)" == "\"healthy\"" ]; do echo "Waiting for qacc-be-graph-ql1 to be healthy..."; sleep 5; done'
if [ $? -eq 124 ]; then
echo "Timeout waiting for qacc-be-graph-ql1 to become healthy"
exit 1
fi
# Check if qacc-be-graph-ql1 is healthy
if [ "$(docker inspect --format='{{json .State.Health.Status}}' qacc-be-graph-ql1)" != "\"healthy\"" ]; then
echo "qacc-be-graph-ql1 is not healthy, stopping deployment"
exit 1
fi
# Check if qacc-be-job is running
if [ "$(docker inspect --format='{{json .State.Status}}' qacc-be-job)" != "\"running\"" ]; then
echo "qacc-be-job is not running, stopping deployment"
exit 1
fi
echo "First deployment phase completed successfully"
rollout-deploy-2:
needs: rollout-deploy-1
runs-on: ubuntu-latest
steps:
- name: SSH and Redeploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd QAcc-BE
## Second Deployment
docker compose down qacc-be-graph-ql2
docker compose up --force-recreate -d qacc-be-graph-ql2
# Wait for qacc-be-graph-ql2 to be healthy (timeout after 5 minutes)
echo "Waiting for qacc-be-graph-ql2 to become healthy..."
timeout 300 bash -c 'until [ "$(docker inspect --format="{{json .State.Health.Status}}" qacc-be-graph-ql2)" == "\"healthy\"" ]; do echo "Waiting for qacc-be-graph-ql2 to be healthy..."; sleep 5; done'
if [ $? -eq 124 ]; then
echo "Timeout waiting for qacc-be-graph-ql2 to become healthy"
exit 1
fi
# Check if qacc-be-graph-ql2 is healthy
if [ "$(docker inspect --format='{{json .State.Health.Status}}' qacc-be-graph-ql2)" != "\"healthy\"" ]; then
echo "qacc-be-graph-ql2 is not healthy, stopping deployment"
exit 1
fi
echo "Second deployment phase completed successfully"
rollout-deploy-3:
needs: rollout-deploy-2
runs-on: ubuntu-latest
steps:
- name: SSH and Redeploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd QAcc-BE
## Third Deployment
docker compose down qacc-be-graph-ql3
docker compose up --force-recreate -d qacc-be-graph-ql3
# Wait for qacc-be-graph-ql3 to be healthy (timeout after 5 minutes)
echo "Waiting for qacc-be-graph-ql3 to become healthy..."
timeout 300 bash -c 'until [ "$(docker inspect --format="{{json .State.Health.Status}}" qacc-be-graph-ql3)" == "\"healthy\"" ]; do echo "Waiting for qacc-be-graph-ql3 to be healthy..."; sleep 5; done'
if [ $? -eq 124 ]; then
echo "Timeout waiting for qacc-be-graph-ql3 to become healthy"
exit 1
fi
# Check if qacc-be-graph-ql3 is healthy
if [ "$(docker inspect --format='{{json .State.Health.Status}}' qacc-be-graph-ql3)" != "\"healthy\"" ]; then
echo "qacc-be-graph-ql3 is not healthy, stopping deployment"
exit 1
fi
echo "First deployment phase completed successfully"