feat: blue and green
This commit is contained in:
@@ -62,11 +62,35 @@ jobs:
|
||||
# DEPLOY
|
||||
# =========================
|
||||
deploy:
|
||||
name: Deploy via Portainer
|
||||
name: Deploy Blue/Green
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Trigger Portainer webhook
|
||||
run: |
|
||||
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}"
|
||||
- name: Deploy via SSH (Blue/Green)
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USER }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
set -e
|
||||
|
||||
echo "📦 Pull latest image"
|
||||
docker pull gitea.leonmorival.com/daily_meal/bemeal-api:latest
|
||||
|
||||
echo "🟢 Start GREEN container"
|
||||
docker compose up -d bemeal-api-green
|
||||
|
||||
echo "⏳ Wait for healthcheck"
|
||||
sleep 10
|
||||
|
||||
curl -f http://localhost/api/health || exit 1
|
||||
|
||||
echo "🔁 Switch traffic (MANUAL STEP OR NPM API)"
|
||||
sed -i 's/blue/green/g' /etc/nginx/conf.d/bemeal.conf
|
||||
nginx -s reload
|
||||
|
||||
echo "🧹 Stop BLUE container"
|
||||
docker stop bemeal-api-blue || true
|
||||
docker rm bemeal-api-blue || true
|
||||
|
||||
Reference in New Issue
Block a user