Skip to content

[plan] Remove individual env var generation from Go compiler #8105

@github-actions

Description

@github-actions

Objective

Clean up the Go compiler to generate only the consolidated GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG JSON instead of 30+ individual environment variables.

Context

This is Phase 5 of the safe output manager refactoring (#8098). After all JavaScript handlers are refactored, remove the individual env var generation from the Go compiler.

Dependencies

  • Requires: #aw_phase4_update to be completed (all handlers refactored)

Target Branch

sot (safe output transition)

Go Files to Modify

  1. pkg/workflow/compiler_safe_outputs_core.go - Core safe output compilation
  2. pkg/workflow/compiler_safe_outputs_issues.go - Issue-specific env vars
  3. pkg/workflow/compiler_safe_outputs_discussions.go - Discussion-specific env vars
  4. pkg/workflow/compiler_safe_outputs_shared.go - Shared env var generation

Implementation Changes

Remove Individual Env Var Functions

Delete or consolidate:

  • generateIssueEnvVars()
  • generateCommentEnvVars()
  • generateDiscussionEnvVars()
  • generateLabelEnvVars()
  • etc. (8+ functions)

Keep Only These Env Vars

  1. GH_AW_SAFE_OUTPUTS_STAGED - Staged mode flag
  2. GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG - JSON configuration

New Config Generation

func generateHandlerConfig(workflow *Workflow) (string, error) {
    config := map[string]interface{}{
        "create_issue": map[string]interface{}{
            "max": workflow.SafeOutputs.Issues.Max,
            "expires": workflow.SafeOutputs.Issues.Expires,
            "allowed_labels": workflow.SafeOutputs.Issues.AllowedLabels,
        },
        "add_comment": map[string]interface{}{
            "max": workflow.SafeOutputs.Comments.Max,
            "hide_older": workflow.SafeOutputs.Comments.HideOlder,
        },
        // ... other handlers
    }
    return json.Marshal(config)
}

Testing

# Run Go tests
make test-unit

# Build and test compilation
make build
./gh-aw compile test-workflow.md

# Verify env vars in output
cat test-workflow.lock.yml | grep "GH_AW_"

Acceptance Criteria

  • Individual env var generation removed
  • Only 2 env vars generated: STAGED and HANDLER_CONFIG
  • JSON config contains all handler settings
  • All Go tests pass
  • Test workflow compiles successfully
  • Compiled workflow has correct env vars structure
    Related to Safe output manager #8098

AI generated by Plan Command for #8098

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions