(config ghAwSetupStepConfig)
| 20 | } |
| 21 | |
| 22 | func generateGhAwSetupStep(config ghAwSetupStepConfig) (GitHubActionStep, error) { |
| 23 | ghAwSetupLog.Printf("Generating gh-aw setup step: action_mode=%s, action_repo=%s, cli_version=%s, with_field_count=%d", |
| 24 | config.actionMode, config.actionRepo, config.cliVersion, len(config.withFields)) |
| 25 | if config.actionMode == ActionModeDev { |
| 26 | ghAwSetupLog.Print("Using dev mode: build and install gh-aw CLI from source") |
| 27 | step := GitHubActionStep{" - name: Build and install gh-aw CLI from source"} |
| 28 | if config.ifCondition != "" { |
| 29 | step = append(step, " if: "+config.ifCondition) |
| 30 | } |
| 31 | step = append(step, |
| 32 | " run: |", |
| 33 | " gh extension remove aw || true", |
| 34 | " make build", |
| 35 | " gh extension install .", |
| 36 | " gh aw version", |
| 37 | " env:", |
| 38 | " GH_TOKEN: ${{ github.token }}", |
| 39 | ) |
| 40 | return step, nil |
| 41 | } |
| 42 | |
| 43 | // Pinning errors are non-fatal: we still emit a valid step with the fallback |
| 44 | // action reference so compilation and workflow execution can continue. |
| 45 | actionRef, pinErr := resolveGhAwSetupActionRef(config) |
| 46 | if pinErr != nil { |
| 47 | ghAwSetupLog.Printf("Action ref resolution returned non-fatal error: %v (using fallback ref %s)", pinErr, actionRef) |
| 48 | } else { |
| 49 | ghAwSetupLog.Printf("Resolved action ref: %s", actionRef) |
| 50 | } |
| 51 | step := GitHubActionStep{ |
| 52 | " - name: Install gh-aw extension", |
| 53 | } |
| 54 | if config.ifCondition != "" { |
| 55 | step = append(step, " if: "+config.ifCondition) |
| 56 | } |
| 57 | step = append(step, " uses: "+actionRef) |
| 58 | step = append(step, " with:") |
| 59 | step = append(step, fmt.Sprintf(" version: '%s'", config.cliVersion)) |
| 60 | |
| 61 | keys := sliceutil.SortedKeys(config.withFields) |
| 62 | for _, key := range keys { |
| 63 | step = append(step, fmt.Sprintf(" %s: %s", key, config.withFields[key])) |
| 64 | } |
| 65 | |
| 66 | return step, pinErr |
| 67 | } |
| 68 | |
| 69 | // resolveGhAwSetupActionRef resolves the setup-cli action reference in priority order: |
| 70 | // 1. Use workflow-aware pin resolution (getActionPinWithData) when WorkflowData exists. |
no test coverage detected