Skip to content

Commit 428cfc6

Browse files
fix(workflow): assign Copilot via GraphQL replaceActorsForAssignable (#19)
The previous Sync from Docs workflow has been failing with HTTP 422 since it tried to create issues with two invalid REST fields: - agent_assignment: {...} (not a valid Issues API field) - assignees: ["copilot-swe-agent[bot]"] (not a valid assignee login) This rewrites the issue-creation step to: 1. Create a plain issue (title/body/labels only) 2. Look up the Copilot bot id via GraphQL suggestedActors 3. Assign Copilot via GraphQL replaceActorsForAssignable ADMIN_GITHUB_TOKEN must belong to a user with a Copilot seat for the assignment to succeed.
1 parent 2122a3a commit 428cfc6

1 file changed

Lines changed: 29 additions & 20 deletions

File tree

.github/workflows/sync-from-docs.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,37 @@ jobs:
7373
--arg services "$CHANGED_SERVICES" \
7474
'"The upstream Docs have been updated. Ensure the affected CLI tools in this monorepo are in sync.\n\n## Changed Services\n\n`" + $services + "`\n\n## Recent Docs Changes\n\n```\n" + $changes + "\n```\n\n## Instructions\n\nThis is a monorepo with CLI tools in subdirectories (luma/, suno/, sora/, etc.).\n\nCheck the AceDataCloud/Docs repo OpenAPI specs at `openapi/<service>.json` for each changed service.\n\nCompare models, endpoints, and parameters against the corresponding subdirectory'\''s code. Fix any differences.\n\nOnly modify subdirectories matching the changed services. If everything is already in sync, close this issue."')
7575
76-
ISSUE_NUM=$(jq -n \
76+
ISSUE_JSON=$(jq -n \
7777
--arg title "sync: update from Docs ($COMMIT_INFO)" \
7878
--argjson body "$body" \
79-
--arg repo "$REPO" \
80-
'{
81-
title: $title,
82-
body: $body,
83-
labels: ["auto-sync"],
84-
assignees: ["copilot-swe-agent[bot]"],
85-
agent_assignment: {
86-
target_repo: $repo,
87-
base_branch: "main",
88-
custom_instructions: "Check out the AceDataCloud/Docs repo and read the openapi/ specs. This is a monorepo — each subdirectory (luma/, suno/, etc.) is a CLI tool. Compare commands and parameters against the Docs specs. Fix any differences. If everything is already in sync, close this issue."
89-
}
90-
}' | gh api \
91-
--method POST \
92-
-H "Accept: application/vnd.github+json" \
93-
-H "X-GitHub-Api-Version: 2022-11-28" \
94-
/repos/"$REPO"/issues \
95-
--input - --jq '.number')
96-
97-
echo "Created issue #$ISSUE_NUM"
79+
'{title: $title, body: $body, labels: ["auto-sync"]}' \
80+
| gh api \
81+
--method POST \
82+
-H "Accept: application/vnd.github+json" \
83+
-H "X-GitHub-Api-Version: 2022-11-28" \
84+
/repos/"$REPO"/issues \
85+
--input -)
86+
ISSUE_NUM=$(echo "$ISSUE_JSON" | jq -r '.number')
87+
ISSUE_NODE=$(echo "$ISSUE_JSON" | jq -r '.node_id')
88+
echo "Created issue #$ISSUE_NUM (node=$ISSUE_NODE)"
89+
90+
OWNER="${REPO%/*}"
91+
NAME="${REPO#*/}"
92+
COPILOT_ID=$(gh api graphql \
93+
-f query='query($owner:String!,$name:String!){ repository(owner:$owner,name:$name){ suggestedActors(capabilities:[CAN_BE_ASSIGNED], first:50){ nodes { __typename ... on Bot { login id } ... on User { login id } } } } }' \
94+
-f owner="$OWNER" -f name="$NAME" \
95+
--jq '[.data.repository.suggestedActors.nodes[] | select(.login=="copilot-swe-agent" or .login=="Copilot")] | .[0].id // empty')
96+
97+
if [ -z "$COPILOT_ID" ]; then
98+
echo "::error::Copilot not found in suggestedActors. ADMIN_GITHUB_TOKEN must belong to a user with a Copilot seat in this org."
99+
gh issue comment "$ISSUE_NUM" --repo "$REPO" --body "Auto-assignment failed: Copilot not visible to ADMIN_GITHUB_TOKEN. Please assign Copilot manually." || true
100+
exit 1
101+
fi
102+
103+
gh api graphql \
104+
-f query='mutation($a:ID!,$b:[ID!]!){ replaceActorsForAssignable(input:{assignableId:$a, actorIds:$b}){ assignable { ... on Issue { number assignees(first:5){ nodes { login } } } } } }' \
105+
-f a="$ISSUE_NODE" -f b="$COPILOT_ID"
106+
98107
echo "issue_number=$ISSUE_NUM" >> "$GITHUB_OUTPUT"
99108
100109
wait-and-merge:

0 commit comments

Comments
 (0)