Skip to content

Commit 8784ee6

Browse files
timrogersCopilothubwriterheiskr
authored
Document how to create an issue and assign it to Copilot with the API (#56596)
Co-authored-by: Copilot <[email protected]> Co-authored-by: hubwriter <[email protected]> Co-authored-by: Kevin Heis <[email protected]>
1 parent 0f8a093 commit 8784ee6

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

content/copilot/how-tos/agents/copilot-coding-agent/using-copilot-to-work-on-an-issue.md

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,70 @@ You can also assign issues to {% data variables.product.prodname_copilot_short %
6262

6363
### Assigning an issue to {% data variables.product.prodname_copilot_short %} via the {% data variables.product.github %} API
6464

65-
You can assign an issue to {% data variables.product.prodname_copilot_short %} by making a request to the GraphQL API.
65+
You can assign issues to {% data variables.product.prodname_copilot_short %} using the GraphQL API.
66+
67+
#### Creating and assigning a new issue
68+
69+
1. Make sure you're authenticating with the API using a user token, for example a {% data variables.product.pat_generic %} or a {% data variables.product.prodname_github_app %} user-to-server token.
70+
1. Verify that {% data variables.copilot.copilot_coding_agent %} is enabled in the repository by checking if the repository's `suggestedActors` in the GraphQL API includes {% data variables.product.prodname_copilot_short %}. Replace `octo-org` with the repository owner, and `octo-repo` with the repository name.
71+
72+
```graphql copy
73+
query {
74+
repository(owner: "octo-org", name: "octo-repo") {
75+
suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {
76+
nodes {
77+
login
78+
__typename
79+
80+
... on Bot {
81+
id
82+
}
83+
84+
... on User {
85+
id
86+
}
87+
}
88+
}
89+
}
90+
}
91+
```
92+
93+
If {% data variables.copilot.copilot_coding_agent %} is enabled for the user and in the repository, the first node returned from the query will have the `login` value `copilot-swe-agent`.
94+
95+
1. Make a note of the `id` value of this login.
96+
97+
1. Fetch the GraphQL global ID of the repository you want to create the issue in, replacing `octo-org` with the repository owner, and `octo-repo` with the repository name.
98+
99+
```graphql copy
100+
query {
101+
repository(owner: "octo-org", name: "octo-repo") {
102+
id
103+
}
104+
}
105+
```
106+
107+
1. 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 step before that.
108+
109+
```graphql copy
110+
mutation {
111+
createIssue(input: {repositoryId: "REPOSITORY_ID", title: "Implement comprehensive unit tests", body: "DETAILS", assigneeIds: ["BOT_ID"]}) {
112+
issue {
113+
id
114+
title
115+
assignees(first: 10) {
116+
nodes {
117+
login
118+
}
119+
}
120+
}
121+
}
122+
}
123+
```
124+
125+
#### Assigning an existing issue
66126

67127
1. Make sure you're authenticating with the API using a user token, for example a {% data variables.product.pat_generic %} or a {% data variables.product.prodname_github_app %} user-to-server token.
68-
1. Verify that {% data variables.copilot.copilot_coding_agent %} is enabled in the repository by checking if the repository's `suggestedActors` in the GraphQL API includes {% data variables.product.prodname_copilot_short %}. Replace `monalisa` with the repository owner, and `octocat` with the name.
128+
1. Verify that {% data variables.copilot.copilot_coding_agent %} is enabled in the repository by checking if the repository's `suggestedActors` in the GraphQL API includes {% data variables.product.prodname_copilot_short %}. Replace `octo-org` with the repository owner, and `octo-repo` with the repository name.
69129

70130
```graphql copy
71131
query {
@@ -103,11 +163,11 @@ You can assign an issue to {% data variables.product.prodname_copilot_short %} b
103163
}
104164
```
105165

106-
1. Assign the issue to {% data variables.product.prodname_copilot_short %} using the `replaceActorsForAssignable` GraphQL mutation. Replace `ISSUE_ID` with the ID returned from the previous step, and `BOT_ID` with the ID returned from the step before that.
166+
1. Assign the existing issue to {% data variables.product.prodname_copilot_short %} using the `replaceActorsForAssignable` mutation. Replace `ISSUE_ID` with the ID returned from the previous step, and `BOT_ID` with the ID returned from the step before that.
107167

108168
```graphql copy
109169
mutation {
110-
replaceActorsForAssignable(input: {assignableId: "ISSUE_ID", assigneeIds: ["BOT_ID"]}) {
170+
replaceActorsForAssignable(input: {assignableId: "ISSUE_ID", actorIds: ["BOT_ID"]}) {
111171
assignable {
112172
... on Issue {
113173
id

0 commit comments

Comments
 (0)