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

Function getActionRef

pkg/cli/copilot_setup.go:24–46  ·  view source on GitHub ↗

getActionRef returns the action reference string based on action mode and version. If a resolver is provided and mode is release or action, attempts to resolve the SHA for a SHA-pinned reference. Falls back to a version tag reference if SHA resolution fails or resolver is nil.

(ctx context.Context, actionMode workflow.ActionMode, version string, resolver workflow.SHAResolver)

Source from the content-addressed store, hash-verified

22// If a resolver is provided and mode is release or action, attempts to resolve the SHA for a SHA-pinned reference.
23// Falls back to a version tag reference if SHA resolution fails or resolver is nil.
24func getActionRef(ctx context.Context, actionMode workflow.ActionMode, version string, resolver workflow.SHAResolver) string {
25 if actionMode.IsRelease() && version != "" && version != "dev" {
26 if resolver != nil {
27 sha, err := resolver.ResolveSHA(ctx, "github/gh-aw-actions/setup-cli", version)
28 if err == nil && sha != "" {
29 return fmt.Sprintf("@%s # %s", sha, version)
30 }
31 copilotSetupLog.Printf("Failed to resolve SHA for setup-cli@%s: %v, falling back to version tag", version, err)
32 }
33 return "@" + version
34 }
35 if actionMode.IsAction() && version != "" && version != "dev" {
36 if resolver != nil {
37 sha, err := resolver.ResolveSHA(ctx, "github/gh-aw-actions/setup-cli", version)
38 if err == nil && sha != "" {
39 return fmt.Sprintf("@%s # %s", sha, version)
40 }
41 copilotSetupLog.Printf("Failed to resolve SHA for gh-aw-actions/setup-cli@%s: %v, falling back to version tag", version, err)
42 }
43 return "@" + version
44 }
45 return "@main"
46}
47
48// generateCopilotSetupStepsYAML generates the copilot-setup-steps.yml content based on action mode
49func generateCopilotSetupStepsYAML(ctx context.Context, actionMode workflow.ActionMode, version string, resolver workflow.SHAResolver) string {

Calls 4

IsReleaseMethod · 0.80
IsActionMethod · 0.80
ResolveSHAMethod · 0.65
PrintfMethod · 0.45

Tested by 1

TestGetActionRefFunction · 0.68