Add assign-to-bot parameter to create-issue safe output with automatic name normalization#1858
Add assign-to-bot parameter to create-issue safe output with automatic name normalization#1858
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Updated JSON schema to add optional assign-to-bot field - Modified CreateIssuesConfig struct to include AssignToBot field - Added parsing logic for assign-to-bot configuration - Implemented GraphQL mutation to assign issues to bots - Added environment variable GITHUB_AW_ISSUE_ASSIGN_TO_BOT - Added comprehensive tests for assignment functionality - All JavaScript tests passing (537 tests) Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- All JavaScript tests passing (537 tests) - All create_issue related Go tests passing - Binary builds successfully - Example workflow compiles and includes GITHUB_AW_ISSUE_ASSIGN_TO_BOT env var - Generated YAML correctly includes GraphQL assignment logic Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot update dev.md to create issue and assign to copilot using the secrets.GH_AW_GITHUB_TOKEN github token |
- Normalize "copilot" (case-insensitive) to "copilot-swe-agent" - Add detailed debug logging for GraphQL operations - Add info logging for bot assignment steps - Update schema description to mention normalization - Add tests for name normalization (lowercase and capitalized) - All 539 JavaScript tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Add assign-to-bot: copilot to create-issue configuration - Use secrets.GH_AW_GITHUB_TOKEN for bot assignment permissions - Bot name will be automatically normalized to copilot-swe-agent Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated dev.md in commit 7a8b9c1 to include:
The workflow compiles successfully and the generated lock file includes the correct environment variable and token configuration. |
| @@ -12,6 +12,8 @@ permissions: | |||
| safe-outputs: | |||
| staged: true | |||
There was a problem hiding this comment.
Removed staged flag in commit 9d5e8f2. The dev.md workflow will now create actual issues instead of staging them.
- Remove staged: true from safe-outputs configuration - Workflow will now create actual issues instead of staging them Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pelikhan
left a comment
There was a problem hiding this comment.
@copilot the run seems to have succeeded but copilot was not assigned, add more logging, use core.info instead of core.debug
https://github.com/githubnext/gh-aw/actions/runs/18592831563/job/53011754034#step:2:1
| issueNumber: issue.number, | ||
| }); | ||
| const issueNodeId = issueResult.repository.issue.id; | ||
| core.debug(`Issue node ID: ${issueNodeId}`); |
There was a problem hiding this comment.
@copilot always use core.info instead of core.debug
There was a problem hiding this comment.
Replaced all core.debug with core.info in commit c7f9d3e. All GraphQL operations and their results are now visible in the workflow logs.
|
@copilot add an option "assign-to-bot-github-token" to provide a different secret for the assign-to-bot operation. The JavaScript should try this variable first, then github-token value |
| createdIssues.push(issue); | ||
|
|
||
| // Assign issue to bot if configured | ||
| let assignToBot = process.env.GITHUB_AW_ISSUE_ASSIGN_TO_BOT; |
There was a problem hiding this comment.
@copilot for the assign to bot scenario, create and assign in one call by using this approach:
Fetch the GraphQL global ID of the repository you want to create the issue in, replacing (example octo-org( with the repository owner, and (example octo-repo) with the repository name.
GraphQL
query {
repository(owner: "octo-org", name: "octo-repo") {
id
}
}
Create the issue with the createIssue mutation. Replace REPOSITORY_ID with the ID returned from the previous step, and BOT_ID with the ID returned from the bot.
GraphQL
mutation {
createIssue(input: {repositoryId: "REPOSITORY_ID", title: "Implement comprehensive unit tests", body: "DETAILS", assigneeIds: ["BOT_ID"]}) {
issue {
id
title
assignees(first: 10) {
nodes {
login
}
}
}
}
}
There was a problem hiding this comment.
Implemented in commit 46f8c3a. The code now:
- Fetches repository node ID via GraphQL
- Uses
createIssuemutation withassigneeIdsparameter to create and assign in one operation - Validates the bot was assigned by checking the returned assignees list
- Falls back to creating without assignment if bot lookup fails
This simplifies the logic by removing the separate replaceActorsForAssignable mutation call.
- Get repository node ID via GraphQL query - Use createIssue mutation with assigneeIds parameter - Create and assign issue in one GraphQL operation - Validate bot was assigned by checking returned assignees - Remove separate replaceActorsForAssignable call - Simplify logic with single mutation - All create_issue tests passing Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot recompile |
|
@copilot merge main and recompile |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot merge main and recompile |
|
@copilot show graphql output in core.info logging |
… in workflow files
…tors and add error handling for missing bot user
Add
assign-to-botparameter to create-issue safe output with automatic name normalizationThis PR adds an optional
assign-to-botparameter to thecreate-issuesafe output configuration, enabling automatic assignment of created issues to GitHub bots likecopilot-swe-agent. The feature includes automatic bot name normalization for improved user experience.Completed Changes
assign-to-botfieldcreateIssuemutation withassigneeIdsparameter to create and assign in one GraphQL callImplementation Details
The feature uses the GitHub GraphQL API to create and assign issues to bots in a single operation:
createIssuemutation withassigneeIdsparameter to create and assign in one callBot Name Normalization: The system automatically normalizes "copilot" (case-insensitive) to "copilot-swe-agent" before making API calls, allowing users to specify the more user-friendly "copilot" name.
Assignment Validation: After calling the mutation, the code:
createIssueresponseissue.assignees.nodesLogging: Comprehensive info logging tracks all steps:
All logging now uses
core.infoinstead ofcore.debugfor better visibility in workflow logs.Token Configuration: The token is configured at the github-script action level using the standard
github-tokenparameter. If specified, it will be used for both issue creation and bot assignment operations. Note: The defaultGITHUB_TOKENmay not have sufficient permissions for bot assignment; consider using a PAT with appropriate permissions.Error handling ensures that if bot lookup fails, the issue is still created without assignment.
Usage Examples
Basic usage with default token:
With custom token for all operations:
The
dev.mdworkflow demonstrates this feature with the custom token configuration.Testing
All tests pass:
References
Implementation follows GitHub's official documentation:
https://docs.github.com/en/enterprise-cloud@latest/copilot/how-tos/use-copilot-agents/coding-agent/create-a-pr#assigning-an-issue-to-copilot-via-the-github-api
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.