Skip to content

Add staged environment variable support to create-pull-request, create-issue, and add-issue-label jobs#792

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-d4a9b7f6-2207-43af-b398-13c824c63b7e
Sep 12, 2025
Merged

Add staged environment variable support to create-pull-request, create-issue, and add-issue-label jobs#792
pelikhan merged 3 commits intomainfrom
copilot/fix-d4a9b7f6-2207-43af-b398-13c824c63b7e

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 12, 2025

The compiler now passes the GITHUB_AW_SAFE_OUTPUTS_STAGED environment variable to the create-pull-request, create-issue, and add-issue-label jobs when the staged flag is set to true in the safe-outputs configuration.

Problem

When workflows are configured with staged: true in their safe-outputs configuration, the staged environment variable was not being passed to the create-pull-request, create-issue, and add-issue-label jobs. This meant that these jobs couldn't operate in staged/preview mode, preventing users from seeing what pull requests, issues, or labels would be created without actually creating them.

Solution

Updated the buildCreateOutputPullRequestJob, buildCreateOutputIssueJob, and buildCreateOutputLabelJob functions in pkg/workflow/compiler.go and pkg/workflow/output_labels.go to include the GITHUB_AW_SAFE_OUTPUTS_STAGED environment variable when data.SafeOutputs.Staged is not nil and is true. The implementation follows the same pattern used in the AI engines (Claude, Codex, Custom) for consistency.

# Before: Environment variables section was missing staged flag
env:
  GITHUB_AW_AGENT_OUTPUT: ${{ needs.main_job.outputs.output }}
  GITHUB_AW_WORKFLOW_ID: "main_job"
  GITHUB_AW_BASE_BRANCH: ${{ github.ref_name }}

# After: Staged flag is included when configured
env:
  GITHUB_AW_AGENT_OUTPUT: ${{ needs.main_job.outputs.output }}
  GITHUB_AW_WORKFLOW_ID: "main_job"
  GITHUB_AW_BASE_BRANCH: ${{ github.ref_name }}
  GITHUB_AW_SAFE_OUTPUTS_STAGED: "true"

Changes

  • Modified pkg/workflow/compiler.go: Added staged environment variable logic to the create-pull-request and create-issue jobs
  • Modified pkg/workflow/output_labels.go: Added staged environment variable logic to the add-issue-label job
  • Added comprehensive tests: Created pkg/workflow/staged_pull_request_test.go, pkg/workflow/staged_create_issue_test.go, and pkg/workflow/staged_add_issue_labels_test.go to verify correct behavior for all scenarios (staged=true, staged=false, staged=nil)
  • Updated workflow lock files: Recompiled all workflows to include the staged environment variable where configured

Testing

All existing tests pass, and new tests specifically verify that:

  • The environment variable is set when staged: true
  • The environment variable is not included when staged: false or unspecified
  • Proper error handling for missing SafeOutputs configuration

This ensures workflows using staged mode will now properly preview pull request creation, issue creation, and label addition without actually performing these actions.

Warning

api.contoso.com

  • Triggering command: /tmp/go-build1940014964/b278/cli.test -test.testlogfile=/tmp/go-build1940014964/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update the compiler to pass the safe output "staged" environment variable to the job that runs create-pull-request Add staged environment variable support to create-pull-request job Sep 12, 2025
Copilot AI requested a review from pelikhan September 12, 2025 16:23
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review and fix "as-labels" and "create-issue" for the same issue

…-label jobs

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 12, 2025

@copilot review and fix "as-labels" and "create-issue" for the same issue

I've reviewed and fixed both "as-labels" (add-issue-label) and "create-issue" for the same issue. Added staged environment variable support to both buildCreateOutputLabelJob and buildCreateOutputIssueJob functions following the same pattern as the create-pull-request job. The fix is complete in commit 144eaa0.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build2253821935/b278/cli.test -test.testlogfile=/tmp/go-build2253821935/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan pelikhan marked this pull request as ready for review September 12, 2025 16:35
Copilot AI changed the title Add staged environment variable support to create-pull-request job Add staged environment variable support to create-pull-request, create-issue, and add-issue-label jobs Sep 12, 2025
@pelikhan pelikhan merged commit b73b936 into main Sep 12, 2025
@pelikhan pelikhan deleted the copilot/fix-d4a9b7f6-2207-43af-b398-13c824c63b7e branch September 12, 2025 16:36
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