Add assignees support to create_issue safe-output job#1930
Conversation
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| 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") |
There was a problem hiding this comment.
@copilot use github token expression that into account the github token authentication configuration (see GH_AW_GITHUB_TOKEN)
There was a problem hiding this comment.
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]
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 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>
Implemented both requested features:
All tests updated and passing. Commit: [short_hash] |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated The compiled workflow correctly maps "copilot" to "copilot-swe-agent" in the assignee step. Commit: [short_hash] |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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 Commit: [short_hash] |
|
@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>
Added Commit: [short_hash] |
| 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") |
There was a problem hiding this comment.
@copilot also make conditional to having issue created
There was a problem hiding this comment.
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>
Added a dedicated section "Assign Issue to GitHub Copilot Agent" in the documentation. The section includes:
Commit: [short_hash] |
| 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. |
There was a problem hiding this comment.
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 | ||
| ``` |
There was a problem hiding this comment.
@copilot add a note that a PAT token is required to assign copilot or any other bot.
There was a problem hiding this comment.
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>
|
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. |
There was a problem hiding this comment.
@copilot use Astro starlight adornment format for note.
There was a problem hiding this comment.
Converted the PAT note to Astro Starlight adornment format using :::note and ::: delimiters for proper rendering in the documentation.
Commit: [short_hash]
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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_issuejob. The implementation is fully backward compatible and includes comprehensive testing.Recent Updates
GH_AW_GITHUB_TOKEN || GITHUB_TOKEN) that respects token precedenceactions/checkout@v5step before assignee operations for gh CLI compatibilityCompleted Tasks
gh issue edit --add-assigneefor each assigneegetEffectiveGitHubToken()for proper token precedenceImplementation Details
1. Core Changes:
Assignees []stringfield toCreateIssuesConfigstructparseIssuesConfig()to parse assignees from YAML (supports both string and array)buildCreateOutputIssueJob()to:getEffectiveGitHubToken()for proper token precedenceactions/checkout@v5step before assignee operations2. Schema Updates:
main_workflow_schema.jsonto accept both string and array of strings usingoneOf3. Documentation:
docs/src/content/docs/reference/safe-outputs.mdwith assignees configuration:::noteadornment format for proper rendering4. Example Workflow:
.github/workflows/dev.mdto create a poem-writing issue assigned to copilot5. Test Coverage:
Example Usage
Array format (multiple assignees):
String format (single assignee):
With PAT for bot assignment:
Generated Output
Complete workflow steps with conditional checkout:
Job permissions:
Security Considerations
getEffectiveGitHubToken()to respect token hierarchycontents: readandissues: writepermissionsactions/checkout@v5for gh CLI operationsTest Results
Files Modified
pkg/workflow/create_issue.go- Added assignees support with token precedence, copilot mapping, and conditional checkout steppkg/workflow/create_issue_assignees_test.go- Updated tests to verify conditional checkout steppkg/workflow/create_issue_assignees_integration_test.go- Added integration tests for conditional checkout steppkg/parser/schemas/main_workflow_schema.json- Updated schema to support string/arraydocs/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 triggerFiles Added
pkg/workflow/create_issue_assignees_test.go- Unit testspkg/workflow/create_issue_assignees_integration_test.go- Integration testspkg/workflow/create_issue_backward_compat_test.go- Compatibility testsOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.