@@ -13,13 +13,18 @@ import (
1313
1414var copilotSetupLog = logger .New ("cli:copilot_setup" )
1515
16+ // getActionRef returns the action reference string based on action mode and version
17+ func getActionRef (actionMode workflow.ActionMode , version string ) string {
18+ if actionMode .IsRelease () && version != "" && version != "dev" {
19+ return "@" + version
20+ }
21+ return "@main"
22+ }
23+
1624// generateCopilotSetupStepsYAML generates the copilot-setup-steps.yml content based on action mode
1725func generateCopilotSetupStepsYAML (actionMode workflow.ActionMode , version string ) string {
1826 // Determine the action reference - use version tag in release mode, @main in dev mode
19- actionRef := "@main"
20- if actionMode .IsRelease () && version != "" && version != "dev" {
21- actionRef = "@" + version
22- }
27+ actionRef := getActionRef (actionMode , version )
2328
2429 if actionMode .IsRelease () {
2530 // Use the actions/setup-cli action in release mode
@@ -247,10 +252,7 @@ func renderCopilotSetupUpdateInstructions(filePath string, actionMode workflow.A
247252 fmt .Fprintln (os .Stderr )
248253
249254 // Determine the action reference
250- actionRef := "@main"
251- if actionMode .IsRelease () && version != "" && version != "dev" {
252- actionRef = "@" + version
253- }
255+ actionRef := getActionRef (actionMode , version )
254256
255257 if actionMode .IsRelease () {
256258 fmt .Fprintln (os .Stderr , " - name: Checkout repository" )
@@ -279,10 +281,7 @@ func upgradeSetupCliVersion(workflow *Workflow, actionMode workflow.ActionMode,
279281 }
280282
281283 upgraded := false
282- actionRef := "@main"
283- if actionMode .IsRelease () && version != "" && version != "dev" {
284- actionRef = "@" + version
285- }
284+ actionRef := getActionRef (actionMode , version )
286285
287286 // Iterate through steps and update any actions/setup-cli steps
288287 for i := range job .Steps {
@@ -321,10 +320,7 @@ func injectExtensionInstallStep(workflow *Workflow, actionMode workflow.ActionMo
321320 var installStep , checkoutStep CopilotWorkflowStep
322321
323322 // Determine the action reference - use version tag in release mode, @main in dev mode
324- actionRef := "@main"
325- if actionMode .IsRelease () && version != "" && version != "dev" {
326- actionRef = "@" + version
327- }
323+ actionRef := getActionRef (actionMode , version )
328324
329325 if actionMode .IsRelease () {
330326 // In release mode, use the actions/setup-cli action
0 commit comments