File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,10 +33,25 @@ jobs:
3333
3434 - name : Deploy to EC2
3535 run : |
36- scp -i private_key.pem -o StrictHostKeyChecking=no \
37- build/libs/*.jar ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:/home/ubuntu/app.jar
36+ max_retries=3
37+ retry_count=0
3838
39- ssh -i private_key.pem -o StrictHostKeyChecking=no \
39+ while [ $retry_count -lt $max_retries ]; do
40+ if scp -i private_key.pem -o StrictHostKeyChecking=no -o ConnectTimeout=10 \
41+ build/libs/*.jar ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }}:/home/ubuntu/app.jar; then
42+ break
43+ fi
44+ retry_count=$((retry_count + 1))
45+ echo "SCP failed. Retrying ($retry_count/$max_retries)..."
46+ sleep 5
47+ done
48+
49+ if [ $retry_count -eq $max_retries ]; then
50+ echo "SCP failed after $max_retries attempts"
51+ exit 1
52+ fi
53+
54+ ssh -i private_key.pem -o StrictHostKeyChecking=no -o ConnectTimeout=10 \
4055 ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
4156 sudo systemctl restart studylink
4257 sudo systemctl status studylink
You can’t perform that action at this time.
0 commit comments