chore: update package #87
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Blog | |
| on: | |
| push: | |
| branches: main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Connect server to deploy blog | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| command_timeout: 20m | |
| script: | | |
| cd ${{ secrets.BLOG_PATH_REMOTE }} | |
| MAX_RETRIES=8 | |
| RETRY_COUNT=0 | |
| while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do | |
| echo "▶️ Attempt $((RETRY_COUNT+1))/$MAX_RETRIES: Pulling code..." | |
| if git pull origin main; then | |
| echo "✅ Git pull succeeded" | |
| docker stop blog || true | |
| docker rm blog || true | |
| docker rmi nextjs || true | |
| docker build -t nextjs . | |
| docker compose up -d | |
| exit 0 | |
| else | |
| echo "❌ Git pull failed (attempt $((RETRY_COUNT+1))/$MAX_RETRIES)" | |
| ((RETRY_COUNT++)) | |
| sleep 5 | |
| fi | |
| done | |
| echo "🛑 Error: Failed to pull code after $MAX_RETRIES attempts" | |
| exit 1 |