Skip to content

post-steps intendation errors #1867

@yaananth

Description

@yaananth

locally copilot made these to workaround:

• Here's the tiny patch I made to the githubnext/gh-aw CLI so post-steps render with valid YAML indentation:

  diff --git a/pkg/workflow/compiler.go b/pkg/workflow/compiler.go
  index d212984..2d4f67d 100644
  --- a/pkg/workflow/compiler.go
  +++ b/pkg/workflow/compiler.go
  @@ -2936,11 +2936,15 @@ func (c *Compiler) generatePostSteps(yaml *strings.Builder, data *WorkflowData)
           lines := strings.Split(data.PostSteps, "\n")
           if len(lines) > 1 {
               for _, line := range lines[1:] {
  -                // Remove 2 existing spaces, add 6
  -                if strings.HasPrefix(line, "  ") {
  -                    yaml.WriteString("    " + line[2:] + "\n")
  -                } else {
  -                    yaml.WriteString("    " + line + "\n")
  -                }
  +                trimmed := strings.TrimRight(line, " ")
  +                if strings.TrimSpace(trimmed) == "" {
  +                    yaml.WriteString("\n")
  +                    continue
  +                }
  +                if strings.HasPrefix(line, "  ") {
  +                    yaml.WriteString("        " + line[2:] + "\n")
  +                } else {
  +                    yaml.WriteString("      " + line + "\n")
  +                }
               }
           }

  What changed and why

  - The generator previously prepended only four spaces, which produced YAML like     - name: … under jobs.agent.steps. GitHub's workflow schema expects list items there
    to start at six spaces (      - …), so schema validation failed whenever we added a post-steps block.
  - I also trim right-hand whitespace and skip empty lines explicitly so the compiler doesn't spew stray spaces when authors leave blank lines inside post-steps.

  After rebuilding (go1.24.5 build ./cmd/gh-aw) and copying the new binary to ~/.local/share/gh/extensions/gh-aw/gh-aw, gh aw compile emits correctly indented YAML, and
  all five workflows now compile without errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions