Added GitHub webhook functionality and configuration for API interaction
This commit introduces functionality for GitHub webhook interaction and API calls. The git operations are handled by a custom GitHub client in PHP, details for API endpoints are outlined in a new OpenAPI schema, and the project setup includes PHP FPM and NGINX configuration using Docker. A webhook receiver is also added to process incoming webhook payloads.
This commit is contained in:
21
src/webhookReceiver.php
Normal file
21
src/webhookReceiver.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
require 'GitHubClient.php';
|
||||
|
||||
$token = getenv('GITHUB_TOKEN');
|
||||
$client = new GitHubClient($token);
|
||||
|
||||
// Get the webhook payload
|
||||
$payload = file_get_contents('php://input');
|
||||
$data = json_decode($payload, true);
|
||||
|
||||
if (isset($data['commits'])) {
|
||||
foreach ($data['commits'] as $commit) {
|
||||
// Process each commit
|
||||
echo "Commit message: " . $commit['message'] . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Respond to GitHub
|
||||
http_response_code(200);
|
||||
echo json_encode(['status' => 'Webhook received']);
|
||||
Reference in New Issue
Block a user