Update MCP PHP SDK #17
Workflow file for this run
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 Killer API to Production | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # Déclenche sur les tags v1.0.0, v2.1.0, etc. | |
| jobs: | |
| deploy: | |
| name: Deploy to Killer API Ubuntu VPS | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| - name: Extract tag name | |
| id: tag | |
| run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Setup SSH | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key | |
| chmod 600 ~/.ssh/deploy_key | |
| ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
| - name: Deploy to server | |
| env: | |
| SSH_HOST: ${{ secrets.SSH_HOST }} | |
| SSH_USER: ${{ secrets.SSH_USER }} | |
| SSH_PORT: ${{ secrets.SSH_PORT || '22' }} | |
| TAG_NAME: ${{ steps.tag.outputs.TAG_NAME }} | |
| run: | | |
| # Créer le fichier avec les variables d'environnement | |
| cat > /tmp/env_vars << EOF | |
| export APP_ENV=prod | |
| export SERVER_NAME="${{ secrets.PROD_SERVER_NAME || 'api.killerparty.app' }}" | |
| export APP_SECRET="${{ secrets.PROD_APP_SECRET }}" | |
| export SENTRY_DSN="${{ secrets.PROD_SENTRY_DSN }}" | |
| export EXPO_DSN="${{ secrets.PROD_EXPO_DSN }}" | |
| export CADDY_MERCURE_JWT_SECRET="${{ secrets.PROD_MERCURE_JWT_SECRET }}" | |
| export DATABASE_URL="${{ secrets.PROD_DATABASE_URL }}" | |
| export APPLE_CLIENT_SECRET="${{ secrets.PROD_APPLE_CLIENT_SECRET }}" | |
| export APPLE_KEY_FILE_ID="${{ secrets.PROD_APPLE_KEY_FILE_ID }}" | |
| export APPLE_TEAM_ID="${{ secrets.PROD_APPLE_TEAM_ID }}" | |
| export TAG_NAME="${{ steps.tag.outputs.TAG_NAME }}" | |
| EOF | |
| scp -i ~/.ssh/deploy_key -P $SSH_PORT /tmp/env_vars $SSH_USER@$SSH_HOST:/tmp/env_vars | |
| # Nettoyer localement | |
| rm /tmp/env_vars | |
| ssh -i ~/.ssh/deploy_key -p $SSH_PORT -o StrictHostKeyChecking=no $SSH_USER@$SSH_HOST << 'ENDSSH' | |
| set -e | |
| source /tmp/env_vars | |
| rm /tmp/env_vars | |
| # Variables | |
| APP_DIR="/home/deploy/KillerAPI" | |
| BRANCH="main" | |
| echo "🚀 Starting deployment of tag: $TAG_NAME" | |
| # Se placer dans le répertoire de l'application | |
| cd $APP_DIR | |
| # Récupérer les dernières modifications | |
| echo "📥 Fetching latest changes from GitHub..." | |
| git fetch --tags origin | |
| # Checkout le tag spécifique | |
| echo "🏷️ Checking out tag: $TAG_NAME" | |
| git checkout ${TAG_NAME} | |
| # Construire la nouvelle image Docker avant d'arrêter les conteneurs | |
| echo "📦 Building new Docker image..." | |
| APP_ENV=$APP_ENV \ | |
| SERVER_NAME="$SERVER_NAME" \ | |
| APP_SECRET="$APP_SECRET" \ | |
| SENTRY_DSN="$SENTRY_DSN" \ | |
| EXPO_DSN="$EXPO_DSN" \ | |
| CADDY_MERCURE_JWT_SECRET="$CADDY_MERCURE_JWT_SECRET" \ | |
| DATABASE_URL="$DATABASE_URL" \ | |
| APPLE_CLIENT_SECRET="$APPLE_CLIENT_SECRET" \ | |
| APPLE_KEY_FILE_ID="$APPLE_KEY_FILE_ID" \ | |
| APPLE_TEAM_ID="$APPLE_TEAM_ID" \ | |
| docker compose -f compose.prod.yaml build php | |
| # Arrêter les conteneurs existants | |
| echo "🛑 Stopping PHP container..." | |
| docker compose -f compose.prod.yaml stop php | |
| docker compose -f compose.prod.yaml rm -f php | |
| # Démarrer les conteneurs avec la nouvelle image | |
| echo "▶️ Starting containers with production configuration..." | |
| APP_ENV=$APP_ENV \ | |
| SERVER_NAME="$SERVER_NAME" \ | |
| APP_SECRET="$APP_SECRET" \ | |
| SENTRY_DSN="$SENTRY_DSN" \ | |
| EXPO_DSN="$EXPO_DSN" \ | |
| CADDY_MERCURE_JWT_SECRET="$CADDY_MERCURE_JWT_SECRET" \ | |
| DATABASE_URL="$DATABASE_URL" \ | |
| APPLE_CLIENT_SECRET="$APPLE_CLIENT_SECRET" \ | |
| APPLE_KEY_FILE_ID="$APPLE_KEY_FILE_ID" \ | |
| APPLE_TEAM_ID="$APPLE_TEAM_ID" \ | |
| docker compose -f compose.prod.yaml up -d --wait --force-recreate --no-deps php | |
| # Attendre que les conteneurs soient prêts | |
| echo "⏳ Waiting for containers to be ready..." | |
| sleep 15 | |
| # Vider le cache | |
| echo "🧹 Clearing cache..." | |
| docker compose -f compose.prod.yaml exec -T php bin/console cache:clear --env=prod || echo "⚠️ Cache clear failed" | |
| # Nettoyer les anciennes images Docker | |
| echo "🧹 Cleaning up old Docker images..." | |
| docker image prune -f | |
| # Vérifier l'état des conteneurs | |
| echo "✅ Checking container status..." | |
| docker compose -f compose.prod.yaml ps | |
| echo "🎉 Deployment of tag $TAG_NAME completed successfully!" | |
| ENDSSH | |
| - name: Notify deployment status | |
| if: always() | |
| run: | | |
| if [ ${{ job.status }} == 'success' ]; then | |
| echo "✅ Deployment of tag ${{ steps.tag.outputs.TAG_NAME }} successful!" | |
| else | |
| echo "❌ Deployment of tag ${{ steps.tag.outputs.TAG_NAME }} failed!" | |
| exit 1 | |
| fi |