Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
31 changes: 19 additions & 12 deletions .github/workflows/changeset-generator.firewall.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 19 additions & 12 deletions .github/workflows/mergefest.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 19 additions & 12 deletions .github/workflows/poem-bot.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 19 additions & 12 deletions .github/workflows/tidy.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 24 additions & 15 deletions pkg/workflow/js/push_to_pull_request_branch.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -256,24 +256,33 @@ async function main() {

// Switch to or create the target branch
core.info(`Switching to branch: ${branchName}`);

// Fetch latest changes from origin
try {
// Try to checkout existing branch first
await exec.exec("git fetch origin");
} catch (fetchError) {
core.setFailed(`Failed to fetch from origin: ${fetchError instanceof Error ? fetchError.message : String(fetchError)}`);
return;
}

// Check if branch exists on origin
try {
await exec.exec(`git rev-parse --verify origin/${branchName}`);
await exec.exec(`git checkout -B ${branchName} origin/${branchName}`);
core.info(`Checked out existing branch from origin: ${branchName}`);
} catch (originError) {
// Give an error if branch doesn't exist on origin
core.setFailed(
`Branch ${branchName} does not exist on origin, can't push to it: ${originError instanceof Error ? originError.message : String(originError)}`
);
return;
}
} catch (error) {
core.setFailed(`Failed to switch to branch ${branchName}: ${error instanceof Error ? error.message : String(error)}`);
// Check if branch exists on origin
try {
await exec.exec(`git rev-parse --verify origin/${branchName}`);
} catch (verifyError) {
core.setFailed(
`Branch ${branchName} does not exist on origin, can't push to it: ${verifyError instanceof Error ? verifyError.message : String(verifyError)}`
);
return;
}

// Checkout the branch from origin
try {
await exec.exec(`git checkout -B ${branchName} origin/${branchName}`);
core.info(`Checked out existing branch from origin: ${branchName}`);
} catch (checkoutError) {
core.setFailed(
`Failed to checkout branch ${branchName}: ${checkoutError instanceof Error ? checkoutError.message : String(checkoutError)}`
);
return;
}

Expand Down
Loading