fix git push auth

This commit is contained in:
David Blass
2025-10-23 16:12:15 -04:00
parent c0f31415a3
commit 1922352d86
6 changed files with 39 additions and 23 deletions
+1 -4
View File
@@ -3,7 +3,7 @@ import { existsSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { config } from "dotenv";
import { buildAction, setupTestRepo } from "./setup.ts";
import { setupTestRepo } from "./setup.ts";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -19,8 +19,6 @@ export function runAct(prompt: string): void {
config({ path: envPath });
buildAction(actionPath);
const workflowPath = join(tempDir, ".github", "workflows", "pullfrog.yml");
const distPath = join(actionPath, ".act-dist");
@@ -54,7 +52,6 @@ export function runAct(prompt: string): void {
}
});
const actCommand = actCommandParts.join(" ");
console.log("🚀 Running act with prompt:");
+26 -7
View File
@@ -1,5 +1,6 @@
import { execSync } from "node:child_process";
import { existsSync, rmSync } from "node:fs";
import type { RepoContext } from "./github.ts";
export interface SetupOptions {
tempDir: string;
@@ -38,12 +39,30 @@ export function setupTestRepo(options: SetupOptions): void {
}
/**
* Build the action bundles
* Setup git configuration to avoid identity errors
*/
export function buildAction(actionPath: string): void {
console.log("🔨 Building fresh bundles with esbuild...");
execSync("node esbuild.config.js", {
cwd: actionPath,
stdio: "inherit",
});
export function setupGitConfig(): void {
console.log("🔧 Setting up git configuration...");
execSync('git config --global user.email "action@pullfrog.ai"', { stdio: "inherit" });
execSync('git config --global user.name "Pullfrog Action"', { stdio: "inherit" });
}
/**
* Setup git authentication using GitHub token
*/
export function setupGitAuth(githubToken: string, repoContext: RepoContext): void {
console.log("🔐 Setting up git authentication...");
// Remove existing git auth headers that actions/checkout might have set
try {
execSync("git config --unset-all http.https://github.com/.extraheader", { stdio: "inherit" });
console.log("✓ Removed existing authentication headers");
} catch {
console.log("No existing authentication headers to remove");
}
// Update remote URL to embed the token
const remoteUrl = `https://x-access-token:${githubToken}@github.com/${repoContext.owner}/${repoContext.name}.git`;
execSync(`git remote set-url origin "${remoteUrl}"`, { stdio: "inherit" });
console.log("✓ Updated remote URL with authentication token");
}