A Cloudflare Worker that assigns GitHub issues to the Copilot coding agent using OAuth authentication.
GitHub's Copilot coding agent can only be assigned to issues via OAuth-authenticated user sessions. PATs and GitHub Apps cannot see copilot-swe-agent as an assignable actor. This Worker holds an OAuth token and exposes a secure endpoint for GitHub Actions workflows to call.
npm install -g wranglerwrangler logincd copilot-assigner-worker
npm installYou need a GitHub OAuth token from an authenticated user session. The easiest way:
Option A: Use gh auth token (if you have GitHub CLI installed and authenticated)
gh auth tokenOption B: Device Flow (manual OAuth flow)
- Go to https://github.com/settings/tokens
- Create a new fine-grained token (or use OAuth App flow)
- But note: Fine-grained PATs may NOT work for Copilot assignment
Option C: Extract from gh CLI's OAuth token
# The gh CLI stores OAuth tokens that have full Copilot access
gh auth token# Set your GitHub OAuth token
wrangler secret put GITHUB_OAUTH_TOKEN
# When prompted, paste your OAuth token
# Generate and set a webhook secret
openssl rand -hex 32
wrangler secret put WEBHOOK_SECRET
# When prompted, paste the generated secretnpm run deployThis will output your Worker URL like: https://copilot-assigner-worker.<your-subdomain>.workers.dev
Add these secrets to your GitHub repository:
COPILOT_WORKER_URL: Your Worker URL (e.g.,https://copilot-assigner-worker.xyz.workers.dev)COPILOT_WORKER_SECRET: The same webhook secret you set in step 5
The Worker accepts POST requests with JSON body:
{
"owner": "your-org",
"repo": "your-repo",
"issue_number": 123
}Headers required:
Content-Type: application/jsonX-Webhook-Secret: <your-webhook-secret>
curl -X POST https://copilot-assigner-worker.xyz.workers.dev \
-H "Content-Type: application/json" \
-H "X-Webhook-Secret: your-secret-here" \
-d '{"owner": "your-org", "repo": "your-repo", "issue_number": 123}'Add this step to your workflow after creating the issue:
- name: Assign to Copilot via Worker
run: |
curl -X POST "${{ secrets.COPILOT_WORKER_URL }}" \
-H "Content-Type: application/json" \
-H "X-Webhook-Secret: ${{ secrets.COPILOT_WORKER_SECRET }}" \
-d '{
"owner": "${{ github.repository_owner }}",
"repo": "${{ github.event.repository.name }}",
"issue_number": ${{ steps.create_issue.outputs.issue_number }}
}'npm run devThis starts a local dev server. You'll need to set environment variables locally for testing.
- Webhook Secret: Always verify the
X-Webhook-Secretheader to prevent unauthorized requests - OAuth Token: Keep your OAuth token secure - it has your GitHub permissions
- CORS: Worker doesn't allow browser requests (no CORS headers) - only server-to-server calls
- Rate Limiting: Consider adding rate limiting if you expect high volume