File tree Expand file tree Collapse file tree 1 file changed +1
-22
lines changed Expand file tree Collapse file tree 1 file changed +1
-22
lines changed Original file line number Diff line number Diff line change @@ -27,19 +27,14 @@ jobs:
2727 SSH_USER : ${{ secrets.SSH_USER }}
2828 BLOG_PATH_REMOTE : ${{ secrets.BLOG_PATH_REMOTE }}
2929 run : |
30- mkdir -p ~/.ssh
31- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
32- chmod 600 ~/.ssh/id_rsa
33- ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts
34- ssh $SSH_USER@$SSH_HOST << 'EOF'
3530 cd $BLOG_PATH_REMOTE
3631
3732 MAX_RETRIES=8
3833 RETRY_COUNT=0
3934
4035 while [ \$RETRY_COUNT -lt \$MAX_RETRIES ]; do
4136 if git pull origin main; then
42- break # pull successful, exit loop
37+ break # pull succesful exit
4338 else
4439 echo "Git pull failed, retrying (\$((RETRY_COUNT + 1)) of \$MAX_RETRIES)..."
4540 ((RETRY_COUNT++))
5247 echo "Failed to pull code after \$MAX_RETRIES attempts. Exiting."
5348 exit 1 # throw error
5449 fi
55-
56- # Build Docker image
57- docker build -t nextjs .
58-
59- # Stop the running container (if any)
60- if docker ps -q --filter "name=blog" | grep -q .; then
61- docker stop blog
62- fi
63-
64- # Remove the stopped container (optional, but recommended for cleanup)
65- if docker ps -aq --filter "name=blog" | grep -q .; then
66- docker rm blog
67- fi
68-
69- # Start the new container using docker-compose
70- docker compose up -d
7150 EOF
You can’t perform that action at this time.
0 commit comments