Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/server/services/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,22 +333,26 @@ export default class GithubService extends Service {
if (!buildId) {
logger.error(`[BUILD ${build?.uuid}][handlePushWebhook][buidIdError] No build ID found for this build!`);
}
// Only check for failed deploys on PR environments, not static environments
let hasFailedDeploys = false;
if (!build.isStatic) {
const failedDeploys = await models.Deploy.query()
.where('buildId', buildId)
.where('active', true)
.whereIn('status', [DeployStatus.ERROR, DeployStatus.BUILD_FAILED, DeployStatus.DEPLOY_FAILED]);

hasFailedDeploys = failedDeploys.length > 0;

if (hasFailedDeploys) {
logger.info(
`[BUILD ${build?.uuid}] Detected ${failedDeploys.length} failed deploy(s). Triggering full redeploy for push on repo: ${repoName} branch: ${branchName}`
);
}
}

// Check if any deploys for this build have failed previously
const failedDeploys = await models.Deploy.query()
.where('buildId', buildId)
.where('active', true)
.whereIn('status', [DeployStatus.ERROR, DeployStatus.BUILD_FAILED, DeployStatus.DEPLOY_FAILED]);

const hasFailedDeploys = failedDeploys.length > 0;

logger.info(
`[BUILD ${build?.uuid}] ${
hasFailedDeploys
? `Detected ${failedDeploys.length} failed deploy(s). Triggering full redeploy`
: 'Deploying build'
} for push on repo: ${repoName} branch: ${branchName}`
);
if (!hasFailedDeploys) {
logger.info(`[BUILD ${build?.uuid}] Deploying build for push on repo: ${repoName} branch: ${branchName}`);
}

await this.db.services.BuildService.resolveAndDeployBuildQueue.add('resolve-deploy', {
buildId,
Expand Down