Skip to content

Commit 6681e71

Browse files
authored
update node version, gh actions, add retry logic (#702)
2 parents 9a74a82 + f75ed54 commit 6681e71

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

.github/workflows/deploy-express.yml

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ jobs:
1212
steps:
1313
- run: echo "🎉 The job was triggered by a ${{ github.event_name }} on commit ${{ github.SHA }}"
1414
- name: Check out repository code
15-
uses: actions/checkout@v2
16-
- uses: actions/setup-node@v3
15+
uses: actions/checkout@v4
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v3
1718
with:
18-
node-version: 16
19+
node-version: 18
1920
cache: 'yarn'
2021
- name: SSH to DO
2122
uses: shimataro/ssh-key-action@v2
@@ -24,8 +25,10 @@ jobs:
2425
name: id_rsa
2526
known_hosts: ${{ secrets.KNOWN_HOSTS }}
2627
- name: Build
28+
env:
29+
YARN_IGNORE_NODE: 1
2730
run: |
28-
npm install -g yarn@1.22.17
31+
npm install -g yarn@1.22.19
2932
npm install -g lerna@3.22.1
3033
lerna bootstrap
3134
cd ./packages/express
@@ -34,6 +37,7 @@ jobs:
3437
yarn build
3538
- name: Deploy and run
3639
run: |
40+
# Create necessary directories
3741
ssh ${{ secrets.DO_USERNAME }}@eduquilt.com mkdir -p /home/skuilder/dist/express/${{github.SHA}}
3842
ssh ${{ secrets.DO_USERNAME }}@eduquilt.com mkdir -p /home/skuilder/dist/express/${{github.SHA}}/assets
3943
@@ -57,19 +61,40 @@ jobs:
5761
# Restart service
5862
ssh -t ${{ secrets.DO_USERNAME }}@eduquilt.com 'echo ${{ secrets.DO_PASSWORD }} | sudo -S systemctl restart eqExpress'
5963
64+
echo "Waiting for service to start..."
6065
sleep 10s
6166
- name: Verify deployment
6267
run: |
63-
response=$(curl -sS https://eduquilt.com/express)
64-
if [[ $? -ne 0 ]]; then
65-
echo "Error: Failed to fetch https://eduquilt.com/express"
66-
exit 1
67-
fi
68-
if echo "$response" | grep -q "${{ github.SHA }}"; then
69-
echo "Success. Current version found in production"
70-
else
71-
echo "Error! Current version not reported by production."
72-
echo "Response received:"
73-
echo "$response"
74-
exit 1
75-
fi
68+
max_retries=3
69+
retry_count=0
70+
while [ $retry_count -lt $max_retries ]; do
71+
response=$(curl -sS https://eduquilt.com/express)
72+
if [[ $? -ne 0 ]]; then
73+
echo "Error: Failed to fetch https://eduquilt.com/express"
74+
retry_count=$((retry_count+1))
75+
if [ $retry_count -lt $max_retries ]; then
76+
echo "Retrying in 5 seconds... (Attempt $retry_count of $max_retries)"
77+
sleep 5
78+
continue
79+
else
80+
exit 1
81+
fi
82+
fi
83+
84+
if echo "$response" | grep -q "${{ github.SHA }}"; then
85+
echo "Success. Current version found in production"
86+
exit 0
87+
else
88+
echo "Current version not found in production. Retrying..."
89+
retry_count=$((retry_count+1))
90+
if [ $retry_count -lt $max_retries ]; then
91+
echo "Retrying in 5 seconds... (Attempt $retry_count of $max_retries)"
92+
sleep 5
93+
else
94+
echo "Error! Max retries reached. Current version not reported by production."
95+
echo "Response received:"
96+
echo "$response"
97+
exit 1
98+
fi
99+
fi
100+
done

0 commit comments

Comments
 (0)