feat(Deployment): Integrate Ansible deployment via PHP deployment pipeline

- Create AnsibleDeployStage using framework's Process module for secure command execution
- Integrate AnsibleDeployStage into DeploymentPipelineCommands for production deployments
- Add force_deploy flag support in Ansible playbook to override stale locks
- Use PHP deployment module as orchestrator (php console.php deploy:production)
- Fix ErrorAggregationInitializer to use Environment class instead of $_ENV superglobal

Architecture:
- BuildStage → AnsibleDeployStage → HealthCheckStage for production
- Process module provides timeout, error handling, and output capture
- Ansible playbook supports rollback via rollback-git-based.yml
- Zero-downtime deployments with health checks
This commit is contained in:
2025-10-26 14:08:07 +01:00
parent a90263d3be
commit 3b623e7afb
170 changed files with 19888 additions and 575 deletions

View File

@@ -0,0 +1,144 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\HttpClient\CurlHttpClient;
use App\Framework\Notification\Channels\Telegram\TelegramClient;
use App\Framework\Notification\Channels\Telegram\TelegramConfig;
use App\Framework\Notification\Channels\Telegram\ValueObjects\{
TelegramChatId,
InlineKeyboard,
InlineKeyboardButton
};
echo "⌨️ Telegram Inline Keyboards Test\n";
echo str_repeat('=', 60) . "\n\n";
try {
// 1. Setup
echo "1⃣ Creating Telegram client...\n";
$config = TelegramConfig::createDefault();
$httpClient = new CurlHttpClient();
$client = new TelegramClient($httpClient, $config);
$chatId = TelegramChatId::fromString('8240973979');
echo " ✅ Client created\n\n";
// 2. Single row with URL buttons
echo "2⃣ Sending message with URL buttons...\n";
try {
$keyboard = InlineKeyboard::singleRow(
InlineKeyboardButton::withUrl('🌐 Visit Website', 'https://example.com'),
InlineKeyboardButton::withUrl('📖 Documentation', 'https://docs.example.com')
);
$response = $client->sendMessage(
chatId: $chatId,
text: "Welcome! Check out these links:",
parseMode: 'Markdown',
keyboard: $keyboard
);
echo " ✅ URL buttons sent! Message ID: {$response->messageId->toString()}\n\n";
} catch (\Throwable $e) {
echo " ❌ Failed: {$e->getMessage()}\n\n";
}
// 3. Single row with callback buttons
echo "3⃣ Sending message with callback buttons...\n";
try {
$keyboard = InlineKeyboard::singleRow(
InlineKeyboardButton::withCallback('✅ Approve', 'approve_order_123'),
InlineKeyboardButton::withCallback('❌ Reject', 'reject_order_123')
);
$response = $client->sendMessage(
chatId: $chatId,
text: "*Order #123*\n\nCustomer ordered 3 items for 49.99€\n\nPlease review:",
parseMode: 'Markdown',
keyboard: $keyboard
);
echo " ✅ Callback buttons sent! Message ID: {$response->messageId->toString()}\n\n";
} catch (\Throwable $e) {
echo " ❌ Failed: {$e->getMessage()}\n\n";
}
// 4. Multi-row keyboard
echo "4⃣ Sending message with multi-row keyboard...\n";
try {
$keyboard = InlineKeyboard::multiRow([
// Row 1: Main actions
[
InlineKeyboardButton::withCallback('✅ Confirm', 'confirm'),
InlineKeyboardButton::withCallback('❌ Cancel', 'cancel'),
],
// Row 2: Secondary actions
[
InlineKeyboardButton::withCallback('⏸️ Pause', 'pause'),
InlineKeyboardButton::withCallback('📝 Edit', 'edit'),
],
// Row 3: Help
[
InlineKeyboardButton::withUrl('❓ Help', 'https://help.example.com'),
]
]);
$response = $client->sendMessage(
chatId: $chatId,
text: "*Payment Processing*\n\nAmount: 99.99€\nMethod: Credit Card\n\nChoose an action:",
parseMode: 'Markdown',
keyboard: $keyboard
);
echo " ✅ Multi-row keyboard sent! Message ID: {$response->messageId->toString()}\n\n";
} catch (\Throwable $e) {
echo " ❌ Failed: {$e->getMessage()}\n\n";
}
// 5. Complex action menu
echo "5⃣ Sending complex action menu...\n";
try {
$keyboard = InlineKeyboard::multiRow([
[
InlineKeyboardButton::withCallback('🎯 Quick Actions', 'menu_quick'),
],
[
InlineKeyboardButton::withCallback('📊 View Stats', 'stats'),
InlineKeyboardButton::withCallback('⚙️ Settings', 'settings'),
],
[
InlineKeyboardButton::withCallback('👤 Profile', 'profile'),
InlineKeyboardButton::withCallback('🔔 Notifications', 'notifications'),
],
[
InlineKeyboardButton::withUrl('🌐 Open Dashboard', 'https://dashboard.example.com'),
]
]);
$response = $client->sendMessage(
chatId: $chatId,
text: "📱 *Main Menu*\n\nWhat would you like to do?",
parseMode: 'Markdown',
keyboard: $keyboard
);
echo " ✅ Complex menu sent! Message ID: {$response->messageId->toString()}\n\n";
} catch (\Throwable $e) {
echo " ❌ Failed: {$e->getMessage()}\n\n";
}
echo "✅ Inline Keyboards test completed!\n\n";
echo "📝 Notes:\n";
echo " - URL buttons open links in browser\n";
echo " - Callback buttons send data back to bot (requires webhook setup)\n";
echo " - Max 64 bytes for callback_data\n";
echo " - Buttons are arranged in rows (max 8 buttons per row)\n";
echo " - Check your Telegram for the interactive messages!\n";
} catch (\Throwable $e) {
echo "\n❌ Test failed: {$e->getMessage()}\n";
echo "Stack trace:\n{$e->getTraceAsString()}\n";
exit(1);
}