opencode icon indicating copy to clipboard operation
opencode copied to clipboard

How to setup opencode github action with copilot provider?

Open blntrsz opened this issue 1 year ago • 28 comments

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

SST Constructs Logs.zip

blntrsz avatar Jul 26 '25 13:07 blntrsz

Add a secret named GH_TOKEN (not GITHUB_TOKEN) then edit the workflows secrets.GITHUB_TOKEN to GH_TOKEN, that works.

MuntasirSZN avatar Jul 26 '25 14:07 MuntasirSZN

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

blntrsz avatar Jul 26 '25 14:07 blntrsz

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?

MuntasirSZN avatar Jul 26 '25 15:07 MuntasirSZN

yep 😢 used with Pro+ subscription

blntrsz avatar Jul 26 '25 16:07 blntrsz

yep 😢 used with Pro+ subscription

Can you try on a public repo (i didn't try) i am using pro (student developer pack) subscription

MuntasirSZN avatar Jul 26 '25 16:07 MuntasirSZN

Having the same issue on a private repo.

elboboua avatar Jul 31 '25 01:07 elboboua

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

lazycoder9 avatar Aug 03 '25 06:08 lazycoder9

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

remorses avatar Aug 10 '25 12:08 remorses

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!

fmatsos avatar Aug 14 '25 10:08 fmatsos

@remorses are you suggesting a change in that file?

chiggly007 avatar Aug 22 '25 00:08 chiggly007

@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.

airtonix avatar Oct 15 '25 06:10 airtonix

I haven't looked into it heavily but I thought copilot was oauth only

rekram1-node avatar Oct 15 '25 06:10 rekram1-node

so a non starter then...

T_T

airtonix avatar Oct 15 '25 06:10 airtonix

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

rekram1-node avatar Oct 15 '25 06:10 rekram1-node

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.

kamilchm avatar Oct 15 '25 08:10 kamilchm

CoPilot CLI apparently authenticates with a PAT and talks to CoPilot, so it looks like it should be possible?

dahjelle avatar Nov 19 '25 23:11 dahjelle

I think? thats new interesting

rekram1-node avatar Nov 20 '25 04:11 rekram1-node

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")

chiggly007 avatar Nov 20 '25 14:11 chiggly007

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

rekram1-node avatar Nov 20 '25 16:11 rekram1-node

FYI: It looks like a PAT in $GITHUB_TOKEN works now after the Copilot authentication changes.

dahjelle avatar Jan 15 '26 19:01 dahjelle