Skip to content

Commit

Permalink
🔊 Add review app creation and update logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelalibert committed Mar 17, 2023
1 parent 53039a5 commit ee9f54c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions build/controllers/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');

const ScalingoClient = require('../../common/services/scalingo-client');
const gitHubService = require('../../common/services/github');
const logger = require('../../common/services/logger');

const repositoryToScalingoAppsReview = {
'pix-bot': ['pix-bot-review'],
Expand Down Expand Up @@ -65,6 +66,10 @@ async function pullRequestOpenedWebhook(request) {

try {
const client = await ScalingoClient.getInstance('reviewApps');
logger.info({
event: 'review-app',
message: `Creating RA for repo ${repository} PR ${prId}`,
});
for (const appName of reviewApps) {
const { app_name: reviewAppName } = await client.deployReviewApp(appName, prId);
await client.disableAutoDeploy(reviewAppName);
Expand All @@ -75,6 +80,10 @@ async function pullRequestOpenedWebhook(request) {
scalingoReviewApps: reviewApps,
pullRequestId: prId,
});
logger.info({
event: 'review-app',
message: `Created RA for repo ${repository} PR ${prId}`,
});
return `Created RA on app ${reviewApps.join(', ')} with pr ${prId}`;
} catch (error) {
throw new Error(`Scalingo APIError: ${error.message}`);
Expand Down Expand Up @@ -103,6 +112,11 @@ async function pullRequestSynchronizeWebhook(request) {
throw new Error(`Scalingo APIError: ${error.message}`);
}

logger.info({
event: 'review-app',
message: `PR${prId} deployement triggered on RA for repo ${repository}`,
});

return `Triggered deployment of RA on app ${reviewApps.join(', ')} with pr ${prId}`;
}

Expand Down

0 comments on commit ee9f54c

Please sign in to comment.