feat(prd-1): implement M1 - platform detection and action.yml modifications
- Add src/platform/detector.ts with 3-tier detection (explicit input, FORGEJO env var, GITHUB_SERVER_URL heuristic) - Add 'platform' input to action.yml (auto/github/forgejo) - Add 'Detect Platform' shell step as first composite action step - Split bun installation: oven-sh/setup-bun for GitHub, curl fallback for Forgejo runners - Condition 'Revoke app token' step to skip on Forgejo - Pass resolved PLATFORM env var to run step - Add 14 unit tests covering all detection paths Progress: M1 complete (1/9 milestones) - M2 and M5 now unblocked Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
411eb3d69d
commit
72f11f320c
4 files changed
+165
-3
No files matched your search
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Platform detection for GitHub vs Forgejo environments.
|
||||
*
|
||||
* Detection priority:
|
||||
* 1. PLATFORM env var (set by action.yml detect step or explicit input)
|
||||
* 2. FORGEJO env var (set by Forgejo runner v7.0+)
|
||||
* 3. GITHUB_SERVER_URL heuristic (non-github.com = Forgejo)
|
||||
* 4. Default to GitHub
|
||||
*/
|
||||
|
||||
export type Platform = "github" | "forgejo";
|
||||
|
||||
export function detectPlatform(): Platform {
|
||||
// 1. Explicit platform from action.yml detect step or user input
|
||||
const platformEnv = process.env.PLATFORM;
|
||||
if (platformEnv === "forgejo") return "forgejo";
|
||||
if (platformEnv === "github") return "github";
|
||||
|
||||
// 2. FORGEJO env var (set by Forgejo runner v7.0+)
|
||||
if (process.env.FORGEJO === "true") return "forgejo";
|
||||
|
||||
// 3. GITHUB_SERVER_URL heuristic — if not github.com, likely Forgejo/Gitea
|
||||
const serverUrl = process.env.GITHUB_SERVER_URL || "";
|
||||
if (serverUrl && !serverUrl.includes("github.com")) {
|
||||
return "forgejo";
|
||||
}
|
||||
|
||||
return "github";
|
||||
}
|
||||
Reference in new issue
Block a user