Attempt to make this work

This commit is contained in:
Mark Wylde
2025-05-30 20:40:22 +01:00
parent c004bcdb83
commit e2d102aadd

View File

@@ -119,7 +119,7 @@ export async function setupBranch(
console.log(`Current SHA: ${currentSHA}`); console.log(`Current SHA: ${currentSHA}`);
// Create branch - try GitHub API first, fallback to Git CLI // Create branch - try GitHub API first
try { try {
await octokits.rest.git.createRef({ await octokits.rest.git.createRef({
owner, owner,
@@ -128,21 +128,16 @@ export async function setupBranch(
sha: currentSHA, sha: currentSHA,
}); });
// If API creation succeeded, checkout the new branch console.log(`Successfully created branch via API: ${newBranch}`);
await $`git fetch origin --depth=1 ${newBranch}`;
await $`git checkout ${newBranch}`;
} catch (createRefError: any) { } catch (createRefError: any) {
// If git/refs creation fails (like in Gitea), fall back to Git CLI // If git/refs creation fails (like in Gitea), that's expected
console.log(`git createRef failed, using Git CLI fallback: ${createRefError.message}`); // We'll create the branch when we push files later
console.log(`git createRef failed (expected for Gitea): ${createRefError.message}`);
// Use Git CLI to create and checkout the branch locally, then push it console.log(`Branch ${newBranch} will be created when files are pushed`);
await $`git checkout -b ${newBranch}`;
await $`git push origin ${newBranch}`;
console.log(`Created branch via Git CLI: ${newBranch}`);
} }
console.log( console.log(
`Successfully created and checked out new branch: ${newBranch}`, `Branch setup completed for: ${newBranch}`,
); );
// Set outputs for GitHub Actions // Set outputs for GitHub Actions