Skip to content

Fix push_to_pull_request_branch to use agent_output.json artifact#1889

Merged
pelikhan merged 4 commits intomainfrom
copilot/upgrade-push-to-pull-request
Oct 17, 2025
Merged

Fix push_to_pull_request_branch to use agent_output.json artifact#1889
pelikhan merged 4 commits intomainfrom
copilot/upgrade-push-to-pull-request

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 17, 2025

Problem

The push_to_pull_request_branch safe-output job was failing because it passed agent output as a direct JSON string instead of using the agent_output.json artifact file. The JavaScript script (push_to_pull_request_branch.cjs) expects GITHUB_AW_AGENT_OUTPUT to be a file path that it can read, but the Go code was passing the JSON content directly via ${{ needs.agent.outputs.output }}.

Error Reference: https://github.com/githubnext/gh-aw/actions/runs/18604513583/job/53050882738#step:5:1

Solution

Updated buildCreateOutputPushToPullRequestBranchJob() in pkg/workflow/push_to_pull_request_branch.go to use the buildGitHubScriptStep() helper function, which is the standard pattern used by other safe-output jobs like create_issue, add_comment, and create_pull_request.

What Changed

Before:

// Pass the agent output content from the main job
steps = append(steps, fmt.Sprintf("GITHUB_AW_AGENT_OUTPUT: ${{ needs.%s.outputs.output }}\n", mainJobName))

After:

// Use buildGitHubScriptStep which automatically:
// 1. Downloads agent_output.json artifact
// 2. Sets GITHUB_AW_AGENT_OUTPUT to file path
scriptSteps := c.buildGitHubScriptStep(data, GitHubScriptStepConfig{
    StepName:      "Push to Branch",
    StepID:        "push_to_pull_request_branch",
    MainJobName:   mainJobName,
    CustomEnvVars: customEnvVars,
    Script:        pushToBranchScript,
    Token:         token,
})

The helper function automatically generates steps to:

  1. Download the agent_output.json artifact to /tmp/gh-aw/safe-outputs/
  2. Set up an environment variable pointing to the artifact file
  3. Pass GITHUB_AW_AGENT_OUTPUT=${{ env.GITHUB_AW_AGENT_OUTPUT }} (file path, not JSON)

Benefits

  • Consistency: Now follows the same pattern as all other safe-output jobs
  • Maintainability: Reduces code duplication and uses shared helper functions
  • Correctness: Fixes the artifact vs. direct output issue
  • Cleaner: Reduced from 54 lines to 48 lines of step-building code

Testing

  • ✅ All unit tests pass (12 push_to_pull_request_branch-specific tests)
  • ✅ All JavaScript tests pass (23 tests in push_to_pull_request_branch.test.cjs)
  • ✅ Integration tests pass
  • ✅ Formatting and linting pass
  • ✅ Recompiled all 64 workflows successfully
  • make agent-finish validation passes
Original prompt

Upgrade the push_to_pull_request_branch to use the agent_ouputs.json artifact instead of the job artifact. See create_issue.cjs.

It currently fails because the code expects a file name not JSON

https://github.com/githubnext/gh-aw/actions/runs/18604513583/job/53050882738#step:5:1


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Updated buildCreateOutputPushToPullRequestBranchJob to use buildGitHubScriptStep helper
- This downloads agent_output.json artifact and sets GITHUB_AW_AGENT_OUTPUT to file path
- Matches pattern used by create_issue and other safe-output jobs
- All tests pass (unit, integration, and JavaScript tests)
- Recompiled all 64 workflows successfully

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Upgrade push_to_pull_request_branch to use agent_outputs.json Fix push_to_pull_request_branch to use agent_output.json artifact Oct 17, 2025
Copilot AI requested a review from pelikhan October 17, 2025 21:09
@pelikhan pelikhan marked this pull request as ready for review October 17, 2025 21:12
@github-actions
Copy link
Copy Markdown
Contributor

Agentic Changeset Generator triggered by this pull request.

@pelikhan pelikhan merged commit 3b1f9eb into main Oct 17, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/upgrade-push-to-pull-request branch October 17, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants