Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.4 KB
Raw Blame
export function githubPrUrl(repoOwner: string, repoName: string, number: number): string {
    return `https://github.com/${repoOwner}/${repoName}/pull/${number}`
}

/** GitHub has no stable by-name workflow URL, so link the Actions list filtered to the workflow. */
export function githubWorkflowUrl(repoOwner: string, repoName: string, workflowName: string): string {
    return `https://github.com/${repoOwner}/${repoName}/actions?query=${encodeURIComponent(`workflow:"${workflowName}"`)}`
}

export function githubRunUrl(repoOwner: string, repoName: string, runId: number): string {
    return `https://github.com/${repoOwner}/${repoName}/actions/runs/${runId}`
}

/** A job's log page. With a step number, the page opens at the first line of that step. */
export function githubJobUrl(
    repoOwner: string,
    repoName: string,
    runId: number,
    jobId: number,
    stepNumber?: number | null
): string {
    return `${githubRunUrl(repoOwner, repoName, runId)}/job/${jobId}${stepNumber == null ? '' : `#step:${stepNumber}:1`}`
}

export function githubCommitUrl(repoOwner: string, repoName: string, sha: string): string {
    return `https://github.com/${repoOwner}/${repoName}/commit/${sha}`
}

/** `repository` is 'owner/name'. HEAD resolves the default branch, whatever it is named. */
export function githubFileUrl(repository: string, file: string): string {
    return `https://github.com/${repository}/blob/HEAD/${file}`
}