Skip to content

Commit 0975aa7

Browse files
authored
Revert "feat(git): support GITHUB_TOKEN env var as netrc auth fallback (#1156)" (#1158)
This reverts commit d863f36.
1 parent 12bc007 commit 0975aa7

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

daemon/git.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const SOURCE_PATH = Deno.env.get("SOURCE_ASSET_PATH");
1818
const DEFAULT_TRACKING_BRANCH = Deno.env.get("DECO_TRACKING_BRANCH") ?? "main";
1919
const REPO_URL = Deno.env.get("DECO_REPO_URL");
2020
const GITHUB_APP_KEY = Deno.env.get("GITHUB_APP_KEY");
21-
const GITHUB_TOKEN = Deno.env.get("GITHUB_TOKEN");
2221
const BUILD_FILES_DIR = Deno.env.get("BUILD_FILES_DIR");
2322
const ADMIN_DOMAIN = "https://admin.deco.cx";
2423

@@ -250,7 +249,7 @@ export const publish = ({ build }: Options): Handler => {
250249
const author = body.author || { name: "decobot", email: "capy@deco.cx" };
251250
const message = body.message || `New release by ${author.name}`;
252251

253-
if (GITHUB_APP_CONFIGURED || GITHUB_APP_KEY || GITHUB_TOKEN) {
252+
if (GITHUB_APP_CONFIGURED || GITHUB_APP_KEY) {
254253
// Re-read the remote URL so we refresh the token for the correct repo
255254
// (important for self-hosted / external repos).
256255
const remoteUrl = await git.remote(["get-url", "origin"]).catch(
@@ -515,20 +514,10 @@ export const setupGithubTokenNetrc = async (
515514
}
516515

517516
// Fallback: fetch token via admin API
518-
if (GITHUB_APP_KEY) {
519-
const token = await getGitHubToken();
520-
if (token !== undefined) {
521-
await updateNetrc(token);
522-
return;
523-
}
524-
// token is undefined (e.g. admin API unavailable) — fall through to GITHUB_TOKEN
525-
}
517+
const token = await getGitHubToken();
518+
if (token === undefined) return;
526519

527-
// Fallback: use a pre-provisioned GITHUB_TOKEN injected by the platform
528-
// (e.g. freestyle environments where a scoped installation token is passed directly).
529-
if (GITHUB_TOKEN) {
530-
await updateNetrc(GITHUB_TOKEN);
531-
}
520+
await updateNetrc(token);
532521
};
533522

534523
/**
@@ -688,7 +677,7 @@ export const ensureGit = async ({
688677
? parseGitHubOwnerRepo(effectiveRepoUrl) ?? undefined
689678
: undefined;
690679

691-
if (GITHUB_APP_CONFIGURED || GITHUB_APP_KEY || GITHUB_TOKEN) {
680+
if (GITHUB_APP_CONFIGURED || GITHUB_APP_KEY) {
692681
await setupGithubTokenNetrc(repoOverride);
693682
}
694683

@@ -697,7 +686,7 @@ export const ensureGit = async ({
697686
return;
698687
}
699688

700-
const useHttps = GITHUB_APP_CONFIGURED || GITHUB_APP_KEY || GITHUB_TOKEN;
689+
const useHttps = GITHUB_APP_CONFIGURED || GITHUB_APP_KEY;
701690
const cloneUrl = repoUrl ??
702691
REPO_URL ??
703692
(useHttps

0 commit comments

Comments
 (0)