MCPcopy Create free account
hub / github.com/github/gh-aw / resolveTopLevelGitHubApp

Function resolveTopLevelGitHubApp

pkg/workflow/workflow_github_app.go:36–51  ·  view source on GitHub ↗

resolveTopLevelGitHubApp resolves the top-level github-app for token minting fallback. Precedence: 1. Current workflow's top-level github-app (explicit override wins) 2. First top-level github-app found across imported shared workflows 3. Nil (no fallback configured)

(frontmatter map[string]any, importsResult *parser.ImportsResult)

Source from the content-addressed store, hash-verified

34// 2. First top-level github-app found across imported shared workflows
35// 3. Nil (no fallback configured)
36func resolveTopLevelGitHubApp(frontmatter map[string]any, importsResult *parser.ImportsResult) *GitHubAppConfig {
37 if app := extractTopLevelGitHubApp(frontmatter); app != nil {
38 return app
39 }
40 if importsResult != nil && importsResult.MergedTopLevelGitHubApp != "" {
41 var appMap map[string]any
42 if err := json.Unmarshal([]byte(importsResult.MergedTopLevelGitHubApp), &appMap); err == nil {
43 app := parseAppConfig(appMap)
44 if app.AppID != "" && app.PrivateKey != "" {
45 workflowGitHubAppLog.Print("Using top-level github-app from imported shared workflow")
46 return app
47 }
48 }
49 }
50 return nil
51}
52
53// topLevelFallbackNeeded reports whether the top-level github-app should be applied as a
54// fallback for a given section. It returns true when the section has neither an explicit

Callers 1

Calls 3

extractTopLevelGitHubAppFunction · 0.85
parseAppConfigFunction · 0.85
PrintMethod · 0.80

Tested by

no test coverage detected