diff --git a/lib/datasource/github-releases/common.ts b/lib/datasource/github-releases/common.ts
index 8b395e47b555300f4dae43f6af7002fa2d02a725..7d23c8cd7e38a18236af9b6b40efff0f634b32a3 100644
--- a/lib/datasource/github-releases/common.ts
+++ b/lib/datasource/github-releases/common.ts
@@ -13,12 +13,18 @@ export function getSourceUrlBase(registryUrl: string): string {
   return ensureTrailingSlash(registryUrl ?? defaultSourceUrlBase);
 }
 
-export function getApiBaseUrl(sourceUrlBase: string): string {
+export function getApiBaseUrl(registryUrl: string): string {
+  const sourceUrlBase = getSourceUrlBase(registryUrl);
   return sourceUrlBase === defaultSourceUrlBase
     ? `https://api.github.com/`
     : `${sourceUrlBase}api/v3/`;
 }
 
+export function getSourceUrl(lookupName: string, registryUrl?: string): string {
+  const sourceUrlBase = getSourceUrlBase(registryUrl);
+  return `${sourceUrlBase}${lookupName}`;
+}
+
 export async function getGithubRelease(
   apiBaseUrl: string,
   repo: string,
diff --git a/lib/datasource/github-releases/index.ts b/lib/datasource/github-releases/index.ts
index 05e09e93d5def102f780d5af579fc76b1400ddae..c7db64bd1a9e93dc81e5fa3ecbbedd5b5618a7ad 100644
--- a/lib/datasource/github-releases/index.ts
+++ b/lib/datasource/github-releases/index.ts
@@ -5,7 +5,7 @@ import {
   cacheNamespace,
   getApiBaseUrl,
   getGithubRelease,
-  getSourceUrlBase,
+  getSourceUrl,
   http,
   id,
 } from './common';
@@ -45,15 +45,14 @@ export async function getReleases({
   if (cachedResult) {
     return cachedResult;
   }
-  const sourceUrlBase = getSourceUrlBase(registryUrl);
-  const apiBaseUrl = getApiBaseUrl(sourceUrlBase);
+  const apiBaseUrl = getApiBaseUrl(registryUrl);
   const url = `${apiBaseUrl}repos/${repo}/releases?per_page=100`;
   const res = await http.getJson<GithubRelease[]>(url, {
     paginate: true,
   });
   const githubReleases = res.body;
   const dependency: ReleaseResult = {
-    sourceUrl: `${sourceUrlBase}${repo}`,
+    sourceUrl: getSourceUrl(repo, registryUrl),
     releases: null,
   };
   dependency.releases = githubReleases.map(
@@ -113,7 +112,7 @@ export async function getDigest(
     return cachedResult;
   }
 
-  const apiBaseUrl = getApiBaseUrl(getSourceUrlBase(registryUrl));
+  const apiBaseUrl = getApiBaseUrl(registryUrl);
   const currentRelease = await getGithubRelease(apiBaseUrl, repo, currentValue);
   const digestAsset = await findDigestAsset(currentRelease, currentDigest);
   let newDigest: string;
diff --git a/lib/datasource/github-tags/index.ts b/lib/datasource/github-tags/index.ts
index 9099448e617d2d6ecc62ef0e5078b425668d2373..c9abc36762a342cad786265334fd42aaa1aa8970 100644
--- a/lib/datasource/github-tags/index.ts
+++ b/lib/datasource/github-tags/index.ts
@@ -1,8 +1,8 @@
 import { logger } from '../../logger';
 import * as packageCache from '../../util/cache/package';
 import { GithubHttp } from '../../util/http/github';
-import { ensureTrailingSlash } from '../../util/url';
 import * as githubReleases from '../github-releases';
+import { getApiBaseUrl, getSourceUrl } from '../github-releases/common';
 import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
 import type { GitHubTag, TagResponse } from './types';
 
@@ -33,14 +33,7 @@ async function getTagCommit(
     return cachedResult;
   }
 
-  // default to GitHub.com if no GHE host is specified.
-  const sourceUrlBase = ensureTrailingSlash(
-    registryUrl ?? 'https://github.com/'
-  );
-  const apiBaseUrl =
-    sourceUrlBase === 'https://github.com/'
-      ? `https://api.github.com/`
-      : `${sourceUrlBase}api/v3/`;
+  const apiBaseUrl = getApiBaseUrl(registryUrl);
   let digest: string;
   try {
     const url = `${apiBaseUrl}repos/${githubRepo}/git/refs/tags/${tag}`;
@@ -93,14 +86,7 @@ export async function getDigest(
   if (cachedResult) {
     return cachedResult;
   }
-  // default to GitHub.com if no GHE host is specified.
-  const sourceUrlBase = ensureTrailingSlash(
-    registryUrl ?? 'https://github.com/'
-  );
-  const apiBaseUrl =
-    sourceUrlBase === 'https://github.com/'
-      ? `https://api.github.com/`
-      : `${sourceUrlBase}api/v3/`;
+  const apiBaseUrl = getApiBaseUrl(registryUrl);
   let digest: string;
   try {
     const url = `${apiBaseUrl}repos/${repo}/commits?per_page=1`;
@@ -138,14 +124,7 @@ async function getTags({
     return cachedResult;
   }
 
-  // default to GitHub.com if no GHE host is specified.
-  const sourceUrlBase = ensureTrailingSlash(
-    registryUrl ?? 'https://github.com/'
-  );
-  const apiBaseUrl =
-    sourceUrlBase === 'https://github.com/'
-      ? `https://api.github.com/`
-      : `${sourceUrlBase}api/v3/`;
+  const apiBaseUrl = getApiBaseUrl(registryUrl);
   // tag
   const url = `${apiBaseUrl}repos/${repo}/tags?per_page=100`;
 
@@ -155,7 +134,7 @@ async function getTags({
     })
   ).body.map((o) => o.name);
   const dependency: ReleaseResult = {
-    sourceUrl: `${sourceUrlBase}${repo}`,
+    sourceUrl: getSourceUrl(repo, registryUrl),
     releases: null,
   };
   dependency.releases = versions.map((version) => ({