Skip to content

Commit

Permalink
log out trigger build
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs committed Dec 7, 2023
1 parent 3667b5d commit 2650e8f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions api/controllers/v2/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ async function prepGithubPushPayload(
githubEvent: PushEvent,
repoBranchesRepository: RepoBranchesRepository,
prefix: string,
repoInfo: ReposBranchesDocsetsDocument
repoInfo: ReposBranchesDocsetsDocument,
directory?: string
): Promise<Omit<EnhancedJob, '_id'>> {
const branch_name = githubEvent.ref.split('/')[2];
const branch_info = await repoBranchesRepository.getRepoBranchAliases(
Expand Down Expand Up @@ -53,6 +54,7 @@ async function prepGithubPushPayload(
urlSlug: urlSlug,
prefix: prefix,
project: project,
directory: directory,
},
logs: [],
};
Expand Down Expand Up @@ -110,15 +112,19 @@ export const TriggerBuild = async (event: APIGatewayEvent): Promise<APIGatewayPr
async function createAndInsertJob(path?: string) {
const repoInfo = await docsetsRepository.getRepo(body.repository.name, path);
const jobPrefix = repoInfo?.prefix ? repoInfo['prefix'][env] : '';
const job = await prepGithubPushPayload(body, repoBranchesRepository, jobPrefix, repoInfo);
const directory = path ? path.slice(1) : undefined;
const job = await prepGithubPushPayload(body, repoBranchesRepository, jobPrefix, repoInfo, directory);

consoleLogger.info(job.title, 'Creating Job');
const jobId = await jobRepository.insertJob(job, c.get('jobsQueueUrl'));
jobRepository.notify(jobId, c.get('jobUpdatesQueueUrl'), JobStatus.inQueue, 0);
consoleLogger.info(job.title, `Created Job ${jobId}`);
}

consoleLogger.info(body.repository.full_name, `IN V2!!! `);

if (process.env.FEATURE_FLAG_MONOREPO_PATH === 'true' && body.repository.name === MONOREPO_NAME) {
consoleLogger.info(body.repository.full_name, `past feature flag and monorepo conditional`);
let monorepoPaths: string[] = [];
try {
if (body.head_commit && body.repository.owner.name) {
Expand All @@ -128,14 +134,15 @@ export const TriggerBuild = async (event: APIGatewayEvent): Promise<APIGatewayPr
ownerName: body.repository.owner.name,
updatedFilePaths: getUpdatedFilePaths(body.head_commit),
});
consoleLogger.info('monoRepoPaths', `Monorepo Paths with new changes: ${monorepoPaths}`);
consoleLogger.info(body.repository.full_name, `Monorepo Paths with new changes: ${monorepoPaths}`);
}
} catch (error) {
console.warn('Warning, attempting to get repo paths caused an error', error);
}

/* Create and insert Job for each monorepo project that has changes */
for (const path of monorepoPaths) {
consoleLogger.info(body.repository.full_name, `Each path: ${path}`);
// TODO: Deal with nested monorepo projects
/* For now, we will ignore nested monorepo projects until necessary */
if (path.split('/').length > 1) continue;
Expand Down

0 comments on commit 2650e8f

Please sign in to comment.