Skip to content

Commit

Permalink
Promise.all()ify scheduled deploy routine
Browse files Browse the repository at this point in the history
  • Loading branch information
casthewiz committed Jul 19, 2022
1 parent c4ab4bc commit 686cc36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions api/controllers/v1/scheduled/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { options as docsLandingOptions } from './repos/docs-landing';

export const DeployDocsLanding = async () => {
const { branches, repoName, repoOwner } = docsLandingOptions;
for (const branch of branches) {
await DeployRepo(repoOwner, repoName, branch)
}
Promise.all(branches.map(branch => {
return DeployRepo(repoOwner, repoName, branch)
})
)

return {
statusCode: 200,
Expand Down
6 changes: 3 additions & 3 deletions api/controllers/v1/scheduled/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ const getDeployableJobs = async (repoOwner:string , repoName:string , branchName

async function deployRepo(deployable: Array<any>, logger: ILogger, jobRepository: JobRepository, jobQueueUrl) {
try {
await jobRepository.insertBulkJobs(deployable, jobQueueUrl);
return jobRepository.insertBulkJobs(deployable, jobQueueUrl);
} catch (err) {
logger.error('deployRepo', err);x
logger.error('deployRepo', err);
}
}

Expand All @@ -155,6 +155,6 @@ export const DeployRepo = async (repoOwner, repoName, branchName): Promise<any>

const deployable = await getDeployableJobs(repoOwner, repoName, branchName, branchRepository);
if (deployable.length > 0) {
await deployRepo(deployable, consoleLogger, jobRepository, c.get('jobsQueueUrl'));
return deployRepo(deployable, consoleLogger, jobRepository, c.get('jobsQueueUrl'));
}
};

0 comments on commit 686cc36

Please sign in to comment.