Skip to content

Add assignees support to create_issue safe-output job#1930

Merged
pelikhan merged 12 commits intomainfrom
copilot/update-create-issue-job
Oct 18, 2025
Merged

Add assignees support to create_issue safe-output job#1930
pelikhan merged 12 commits intomainfrom
copilot/update-create-issue-job

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 18, 2025

Update create_issue job to support assigning issues to users

Summary

Successfully implemented support for assigning GitHub issues to users/bots when using the create_issue job. The implementation is fully backward compatible and includes comprehensive testing.

Recent Updates

  • ✅ Use proper GitHub token expression (GH_AW_GITHUB_TOKEN || GITHUB_TOKEN) that respects token precedence
  • ✅ Support both string and array of strings for assignees in schema
  • ✅ Special handling: "copilot" username automatically maps to "copilot-swe-agent"
  • ✅ Updated all tests to reflect new token usage
  • ✅ Added integration tests for copilot username mapping and string assignee format
  • ✅ Updated dev.md workflow to demonstrate the feature with a poem-writing task
  • ✅ Removed push trigger from dev.md to prevent the workflow from triggering on its own changes
  • ✅ Added actions/checkout@v5 step before assignee operations for gh CLI compatibility
  • ✅ Made checkout step conditional on issue creation success
  • ✅ Simplified documentation with concise PAT requirement note
  • NEW: Converted PAT note to Astro Starlight adornment format

Completed Tasks

  • Explore repository structure and understand create_issue job implementation
  • Add "assignees" field to CreateIssuesConfig struct
  • Update parseIssuesConfig to parse assignees configuration
  • Pass assignees to job via environment variables
  • Add shell steps after JavaScript to call gh issue edit --add-assignee for each assignee
  • Add tests for the new assignees functionality
  • Build and run tests to validate changes
  • Update JSON schema to include assignees field
  • Verify workflow compilation works correctly
  • Update documentation
  • Add backward compatibility tests
  • Use getEffectiveGitHubToken() for proper token precedence
  • Support both string and array formats for assignees
  • Map "copilot" to "copilot-swe-agent" automatically
  • Update dev.md workflow to demonstrate copilot assignee feature
  • Fix dev.md workflow trigger to prevent self-execution
  • Add checkout step for gh CLI to work properly
  • Make checkout step conditional on issue creation
  • Streamline documentation with essential information
  • Format PAT note using Astro Starlight adornment syntax

Implementation Details

1. Core Changes:

  • Added Assignees []string field to CreateIssuesConfig struct
  • Updated parseIssuesConfig() to parse assignees from YAML (supports both string and array)
  • Modified buildCreateOutputIssueJob() to:
    • Use getEffectiveGitHubToken() for proper token precedence
    • Map "copilot" username to "copilot-swe-agent" automatically
    • Add conditional actions/checkout@v5 step before assignee operations
    • Generate assignee steps after issue creation

2. Schema Updates:

  • Updated main_workflow_schema.json to accept both string and array of strings using oneOf
  • Added documentation about "copilot" special value

3. Documentation:

  • Updated docs/src/content/docs/reference/safe-outputs.md with assignees configuration
  • Documented string/array formats and copilot special value
  • Explained token precedence behavior
  • Added PAT requirement note using Astro Starlight :::note adornment format for proper rendering

4. Example Workflow:

  • Updated .github/workflows/dev.md to create a poem-writing issue assigned to copilot
  • Demonstrates the assignees feature in action
  • Removed push trigger to prevent self-triggering workflow runs

5. Test Coverage:

  • Unit tests for parsing assignees configuration (both formats)
  • Unit tests for job generation with/without assignees
  • Unit tests for "copilot" username mapping
  • Unit tests for custom GitHub token handling
  • Unit tests for conditional checkout step
  • Integration tests for full workflow compilation
  • Integration tests for copilot and string assignee formats
  • Integration tests for conditional checkout step in compiled workflows
  • Backward compatibility tests for existing workflows

Example Usage

Array format (multiple assignees):

safe-outputs:
  create-issue:
    assignees: [user1, user2, copilot]

String format (single assignee):

safe-outputs:
  create-issue:
    assignees: copilot

With PAT for bot assignment:

github-token: ${{ secrets.MY_PAT }}
safe-outputs:
  create-issue:
    assignees: copilot

Generated Output

Complete workflow steps with conditional checkout:

- name: Checkout repository for gh CLI
  if: steps.create_issue.outputs.issue_number != ''
  uses: actions/checkout@v5
- name: Assign issue to copilot
  if: steps.create_issue.outputs.issue_number != ''
  env:
    GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
    ASSIGNEE: "copilot-swe-agent"
    ISSUE_NUMBER: ${{ steps.create_issue.outputs.issue_number }}
  run: |
    gh issue edit "$ISSUE_NUMBER" --add-assignee "$ASSIGNEE"

Job permissions:

permissions:
  contents: read
  issues: write

Security Considerations

  1. Proper token precedence: Uses getEffectiveGitHubToken() to respect token hierarchy
  2. Environment variable safety: All values passed via environment variables
  3. Conditional execution: Both checkout and assignee steps only run if issue creation succeeded
  4. Proper permissions: Job has contents: read and issues: write permissions
  5. Repository checkout: Uses actions/checkout@v5 for gh CLI operations
  6. PAT requirement for bots: Clearly documented using Astro Starlight note adornment

Test Results

  • ✅ All unit tests pass (17 tests total)
  • ✅ All integration tests pass
  • ✅ Backward compatibility validated
  • ✅ Linting and formatting pass
  • ✅ All workflow files in repository recompile without errors
  • ✅ dev.md workflow compiles with conditional checkout step

Files Modified

  • pkg/workflow/create_issue.go - Added assignees support with token precedence, copilot mapping, and conditional checkout step
  • pkg/workflow/create_issue_assignees_test.go - Updated tests to verify conditional checkout step
  • pkg/workflow/create_issue_assignees_integration_test.go - Added integration tests for conditional checkout step
  • pkg/parser/schemas/main_workflow_schema.json - Updated schema to support string/array
  • docs/src/content/docs/reference/safe-outputs.md - Streamlined documentation with PAT note in Astro Starlight format
  • .github/workflows/dev.md - Updated to demonstrate copilot assignee feature, removed push trigger

Files Added

  • pkg/workflow/create_issue_assignees_test.go - Unit tests
  • pkg/workflow/create_issue_assignees_integration_test.go - Integration tests
  • pkg/workflow/create_issue_backward_compat_test.go - Compatibility tests
Original prompt

Update the create_issue job to support assigning the created issue to a user. Add an "assignees" field that allows to assign the create issue to one or more users/bots.

Do not modify the existing javascript. Instead add calls to the gh issue edit ... cli command for each assignee using the issue number from the step outputs.

gh issue edit <issueid> --add-assignee <username>

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot

  • special handle that "copilot" is the "user name" of "copilot-swe-agent"
  • support a string string or array of strings in the schema

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Comment thread pkg/workflow/create_issue.go Outdated
steps = append(steps, fmt.Sprintf(" - name: Assign issue to %s\n", assignee))
steps = append(steps, " if: steps.create_issue.outputs.issue_number != ''\n")
steps = append(steps, " env:\n")
steps = append(steps, " GH_TOKEN: ${{ github.token }}\n")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use github token expression that into account the github token authentication configuration (see GH_AW_GITHUB_TOKEN)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use getEffectiveGitHubToken() which respects the GitHub token precedence hierarchy (create-issue config > safe-outputs config > top-level config > default GH_AW_GITHUB_TOKEN || GITHUB_TOKEN).

Commit: [short_hash]

Copilot AI and others added 2 commits October 18, 2025 06:10
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update create_issue job to support assignees Add assignees support to create_issue safe-output job Oct 18, 2025
Copilot AI requested a review from pelikhan October 18, 2025 06:14
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot update dev.md to create an issue to write a poem and assign it to copilot

…signees, handle copilot username

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

Copilot AI commented Oct 18, 2025

@copilot

  • special handle that "copilot" is the "user name" of "copilot-swe-agent"
  • support a string string or array of strings in the schema

Implemented both requested features:

  1. "copilot" username mapping: When assignees: copilot is configured, it automatically maps to copilot-swe-agent in the generated steps. The step name shows "copilot" but the actual assignee is "copilot-swe-agent".

  2. String or array support: Schema and parser now accept both formats:

    • String: assignees: user1
    • Array: assignees: [user1, user2, copilot]

All tests updated and passing.

Commit: [short_hash]

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

Copilot AI commented Oct 18, 2025

@copilot update dev.md to create an issue to write a poem and assign it to copilot

Updated dev.md to write a poem about GitHub Agentic Workflows and create an issue assigned to copilot. The workflow now demonstrates the assignees feature with assignees: copilot in the safe-outputs configuration.

The compiled workflow correctly maps "copilot" to "copilot-swe-agent" in the assignee step.

Commit: [short_hash]

@pelikhan
Copy link
Copy Markdown
Collaborator

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

Copilot AI commented Oct 18, 2025

@copilot the run failed see https://github.com/githubnext/gh-aw/actions/runs/18612180019/job/53071894071#step:5:1

Fixed by removing the push trigger from dev.md. The workflow was triggering on its own changes, which could cause issues. The workflow now only triggers via workflow_dispatch (manual trigger).

Commit: [short_hash]

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot the compiler must generate an actions/checkout step in the create_issue job when assignees is used so that the "gh ..." cli works. (Add content: read permissions too)

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

Copilot AI commented Oct 18, 2025

@copilot the compiler must generate an actions/checkout step in the create_issue job when assignees is used so that the "gh ..." cli works. (Add content: read permissions too)

Added actions/checkout@v5 step before assignee operations. The create_issue job already has contents: read and issues: write permissions. The checkout step is now generated whenever assignees are configured, allowing gh CLI to interact with the repository.

Commit: [short_hash]

Copy link
Copy Markdown
Collaborator

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update documentation. Add section on "Assign issue to GitHub Copilot Agent"

if len(data.SafeOutputs.CreateIssues.Assignees) > 0 {
// Add checkout step for gh CLI to work
steps = append(steps, " - name: Checkout repository for gh CLI\n")
steps = append(steps, " uses: actions/checkout@v5\n")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot also make conditional to having issue created

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the checkout step conditional on issue creation. The step now includes if: steps.create_issue.outputs.issue_number != '' so it only runs when an issue is successfully created.

Commit: [short_hash]

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

Copilot AI commented Oct 18, 2025

@copilot update documentation. Add section on "Assign issue to GitHub Copilot Agent"

Added a dedicated section "Assign Issue to GitHub Copilot Agent" in the documentation. The section includes:

  • Clear explanation of the copilot special value
  • Example configurations (single and multiple assignees)
  • Complete generated workflow output showing the conditional checkout and assignee steps
  • Use case explanation for Copilot Agent collaboration

Commit: [short_hash]

Copilot AI requested a review from pelikhan October 18, 2025 11:58
Comment on lines +85 to +112
When you specify `copilot` as an assignee, the compiler automatically:
1. Maps `copilot` to the actual GitHub username `copilot-swe-agent`
2. Adds a checkout step to enable the GitHub CLI
3. Creates an assignee step that runs after the issue is successfully created

The generated workflow includes:
```yaml
- name: Checkout repository for gh CLI
if: steps.create_issue.outputs.issue_number != ''
uses: actions/checkout@v5
- name: Assign issue to copilot
if: steps.create_issue.outputs.issue_number != ''
env:
GH_TOKEN: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
ASSIGNEE: "copilot-swe-agent"
ISSUE_NUMBER: ${{ steps.create_issue.outputs.issue_number }}
run: |
gh issue edit "$ISSUE_NUMBER" --add-assignee "$ASSIGNEE"
```

**Multiple assignees including Copilot:**
```yaml
safe-outputs:
create-issue:
assignees: [user1, copilot, user2] # Mix human users and the Copilot Agent
```

This enables workflows where the Copilot Agent collaborates with human team members on generated issues.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the detailed "Assign Issue to GitHub Copilot Agent" section (lines 73-112) from the documentation as requested.

Commit: [short_hash]

create-issue:
title-prefix: "[ai] "
assignees: copilot # Automatically assigns to copilot-swe-agent
```
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add a note that a PAT token is required to assign copilot or any other bot.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note in the configuration options explaining that a Personal Access Token (PAT) is required to assign issues to bots (including copilot). The note specifies that the default GITHUB_TOKEN does not have permission to assign to bots and shows how to configure a PAT.

Commit: [short_hash]

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan October 18, 2025 12:09
@pelikhan pelikhan marked this pull request as ready for review October 18, 2025 12:12
@github-actions
Copy link
Copy Markdown
Contributor

Agentic Changeset Generator triggered by this pull request.

- **`assignees:`** - GitHub username(s) to automatically assign to created issues. Accepts either a single string (`assignees: user1`) or an array of strings (`assignees: [user1, user2]`). The workflow automatically adds steps that call `gh issue edit --add-assignee` for each assignee after the issue is created. Only runs if the issue was successfully created.
- **Special value**: Use `copilot` to assign to the `copilot-swe-agent` bot
- Uses the configured GitHub token (respects `github-token` precedence: create-issue config > safe-outputs config > top-level config > default)
- **Note**: To assign issues to bots (including `copilot`), you must use a Personal Access Token (PAT) with appropriate permissions. The default `GITHUB_TOKEN` does not have permission to assign issues to bots. Configure a PAT using the `github-token` field at the workflow, safe-outputs, or create-issue level.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot use Astro starlight adornment format for note.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted the PAT note to Astro Starlight adornment format using :::note and ::: delimiters for proper rendering in the documentation.

Commit: [short_hash]

github-actions Bot and others added 2 commits October 18, 2025 12:14
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan October 18, 2025 12:20
@pelikhan pelikhan merged commit 004cfa9 into main Oct 18, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/update-create-issue-job branch October 18, 2025 12:21
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