How to setup opencode github action with copilot provider?
Problem
Cannot setup OpenCode Github agent using the copilot provider. The instructions suggests that I should use the GITHUB_TOKEN but none of that worked
Tryed approches
- bulit in GITHUB_TOKEN with permissions in the GH Action
permissions:
contents: write
id-token: write
issues: write
pull-requests: write
models: read
- personal access token with all access
- fine grained token with all access
gh auth token
Error log
Add a secret named GH_TOKEN (not GITHUB_TOKEN) then edit the workflows secrets.GITHUB_TOKEN to GH_TOKEN, that works.
Hey @MuntasirSZN thank you, but I already tried that one, with all possible token options:
- personal access token with all access
- fine grained token with all access
- gh cli:
gh auth token
Hey @MuntasirSZN thank you, but I already tried that one, with all possible token options:
- personal access token with all access
- fine grained token with all access
- gh cli:
gh auth token
🤦♂️ it stopped working.... Are you using on a private repo like me?
yep 😢 used with Pro+ subscription
yep 😢 used with Pro+ subscription
Can you try on a public repo (i didn't try) i am using pro (student developer pack) subscription
Having the same issue on a private repo.
If anyone has working setup opencode + Github Action + Github Copilot provider I would appreciate if you can share your workflow file. I can't make it work even on public repos, I'm continiously getting this error:
error: {
name: "UnknownError",
data: {
message: "AI_APICallError: Bad Request",
},
}
And I don't know what is wrong
It looks like the opencode Copilot provider only supports oauth for now https://github.com/sst/opencode/blob/c478d1bdbbb5165b7d5921d96d9c2ee8f55e8afa/packages/opencode/src/provider/provider.ts#L78
If anyone has working setup opencode + Github Action + Github Copilot provider I would appreciate if you can share your workflow file. I can't make it work even on public repos, I'm continiously getting this error:
error: { name: "UnknownError", data: { message: "AI_APICallError: Bad Request", }, }And I don't know what is wrong
Also tried to configure Github Action with opencode, and get the same error. Auth seems to work, since we go until the API call.
Here my Github Action configuration:
name: opencode
on:
issue_comment:
types: [created]
jobs:
opencode:
if: |
contains(github.event.comment.body, ' /oc') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
startsWith(github.event.comment.body, '/opencode')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
issues: write
pull-requests: write
models: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run opencode
uses: sst/opencode/github@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
model: github-copilot/claude-sonnet-4
And part of job output:
error: {
name: "UnknownError",
data: {
message: "AI_APICallError: Bad Request",
},
},
}
124351 | }
124352 | ])
124353 | ]
124354 | });
124355 | if (result.info.error) {
124356 | throw new Error(`${result.info.error.name}: ${"message" in result.info.error ? result.info.error.message : ""}`);
^
error: UnknownError:
at chat (/$bunfs/root/opencode:124356:17)
Hope it can help!
@remorses are you suggesting a change in that file?
@remorses are you suggesting a change in that file?
Seems like this the case.
It would have to support authentication via one of githubs other authentication methods. I'm not heaps familiar but I'm aware that there's methods that are required when using an App.
The opencode github app would also need to be updated.
I haven't looked into it heavily but I thought copilot was oauth only
so a non starter then...
T_T
things may have changed since i last checked but i feel like thats what I recall, because you cant talk to copilot with a PAT
Not exactly about using OpenCode in GH Actions, but I wrote about how to use your Copilot subscription in GH Actions here: https://kamil.chm.ski/github-copilot-actions-quickstart. It should be pretty easy to run OpenCode in a workflow that way.
CoPilot CLI apparently authenticates with a PAT and talks to CoPilot, so it looks like it should be possible?
I think? thats new interesting
so some sort of update to the below based on @dahjelle comment?
It looks like the opencode Copilot provider only supports oauth for now
opencode/packages/opencode/src/provider/provider.ts
Line 78 in c478d1b
const info = await Auth.get("github-copilot")
Yeah we would need to update to get that working, would need some type of change either here: https://github.com/sst/opencode-copilot-auth
Or in provider.ts in opencode codebase
Can check it out when I get a chance
FYI: It looks like a PAT in $GITHUB_TOKEN works now after the Copilot authentication changes.