Skip to content

Commit

Permalink
Merge branch 'main' into EVEREST-1547-upgrade-reload-everest-dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
percona-robot authored Jan 22, 2025
2 parents 65cdc8d + b4a2647 commit 0fde094
Showing 1 changed file with 41 additions and 28 deletions.
69 changes: 41 additions & 28 deletions .github/workflows/auto-update-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,39 @@ jobs:
for (const pull of pulls) {
const hasAutoUpdateLabel = pull.labels.some(label => label.name === "auto-update-base");
if (hasAutoUpdateLabel) {
try {
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull.number,
});
if (!hasAutoUpdateLabel) {
continue;
}
try {
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull.number,
});
switch (pr.mergeable) {
case null:
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - GitHub is still computing the mergeability. Will retry later.`);
retriesNeeded = true;
break;
case false:
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - Skipping update due to merge conflict.`);
break;
case true:
console.log(`[INFO] Base branch: ${pr.base.ref} - Base branch SHA: ${pr.base.sha}`);
try {
const { data: baseBranch } = await github.rest.repos.getBranch({
owner: context.repo.owner,
repo: context.repo.repo,
branch: pr.base.ref,
});
if (pr.base.sha === baseBranch.commit.sha) {
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - Base branch is already up-to-date.`);
break;
}
switch (pr.data.mergeable_state) {
case 'unknown':
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - GitHub is still computing the mergeability. Will retry later.`);
retriesNeeded = true;
break;
case 'clean':
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - Base branch is up-to-date.`);
break;
case 'dirty':
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - Skipping update due to merge conflict.`);
break;
case 'blocked':
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - Skipping update due to blocked status.`);
break;
case 'behind':
console.log(`[UPDATE] PR #${pull.number}: "${pull.title}" - Updating base branch...`);
try {
await github.rest.pulls.updateBranch({
Expand All @@ -67,14 +77,17 @@ jobs:
console.error(`[ERROR] PR #${pull.number}: Failed to update base branch - ${updateError.message}`);
errorEncountered = true;
}
break;
} catch (baseError) {
console.error(`[ERROR] PR #${pull.number}: Failed to get base branch - ${baseError.message}`);
errorEncountered = true;
break;
default:
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - Mergeable state: ${pr.data.mergeable_state}. Cannot update base branch.`);
}
} catch (diffError) {
console.error(`[ERROR] PR #${pull.number}: Failed to compare commits - ${diffError.message}`);
errorEncountered = true;
}
}
} catch (prError) {
console.error(`[ERROR] Failed to get PR #${pull.number} - ${prError.message}`);
errorEncountered = true;
}
}
} catch (error) {
Expand Down

0 comments on commit 0fde094

Please sign in to comment.