fix: move origin URL auth setup before git fetch in setupGit
This commit is contained in:
@@ -11,6 +11,8 @@ export interface WorkflowRunInfo {
|
||||
owner: string;
|
||||
repo: string;
|
||||
runId: string;
|
||||
/** optional job URL - if provided, will be used instead of building from runId */
|
||||
htmlUrl?: string;
|
||||
}
|
||||
|
||||
export interface BuildPullfrogFooterParams {
|
||||
@@ -40,9 +42,8 @@ export function buildPullfrogFooter(params: BuildPullfrogFooterParams): string {
|
||||
}
|
||||
|
||||
if (params.workflowRun) {
|
||||
parts.push(
|
||||
`[View workflow run](https://github.com/${params.workflowRun.owner}/${params.workflowRun.repo}/actions/runs/${params.workflowRun.runId})`
|
||||
);
|
||||
const url = params.workflowRun.htmlUrl ?? `https://github.com/${params.workflowRun.owner}/${params.workflowRun.repo}/actions/runs/${params.workflowRun.runId}`;
|
||||
parts.push(`[View workflow run](${url})`);
|
||||
}
|
||||
|
||||
if (params.customParts) {
|
||||
|
||||
+6
-4
@@ -87,11 +87,13 @@ export async function setupGit(ctx: Context): Promise<SetupGitResult> {
|
||||
log.debug("No existing authentication headers to remove");
|
||||
}
|
||||
|
||||
// non-PR events: set up origin with token, stay on default branch
|
||||
// set up origin with token (needed for fetch operations)
|
||||
const originUrl = `https://x-access-token:${ctx.githubInstallationToken}@github.com/${ctx.owner}/${ctx.name}.git`;
|
||||
$("git", ["remote", "set-url", "origin", originUrl], { cwd: repoDir });
|
||||
log.info("✓ Updated origin URL with authentication token");
|
||||
|
||||
// non-PR events: stay on default branch
|
||||
if (ctx.payload.event.is_pr !== true || !ctx.payload.event.issue_number) {
|
||||
const originUrl = `https://x-access-token:${ctx.githubInstallationToken}@github.com/${ctx.owner}/${ctx.name}.git`;
|
||||
$("git", ["remote", "set-url", "origin", originUrl], { cwd: repoDir });
|
||||
log.info("✓ Updated origin URL with authentication token");
|
||||
return { pushRemote: "origin" };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user