Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using 'run' cmd in Github action returns 'unauthorized' code (missing permissions) #35

Closed
elyonz opened this issue Jan 28, 2025 · 1 comment

Comments

@elyonz
Copy link

elyonz commented Jan 28, 2025

Just a simple run command will return an error in any Github Action workflow. Is there a permission that we can set to enable it? (not that I could find..)

workflow.yml

name: Test GPT

jobs:
  test:
    name: GPT
    runs-on: ubuntu-latest
    env:
      GH_TOKEN: ${{ github.token }}
    steps:
      - uses: actions/checkout@v4

      - name: Install GH CLI (when using private runners)
        uses: dev-hanz-ops/[email protected]
        with:
          gh-cli-version: 2.65.0

      - name: Install GH CLI models extension
        run: |
          gh extension install https://github.com/github/gh-models

      - name: Generate Text
        run: |
          test=$(gh models run gpt-4o "Hello?" | head -n 1)
          echo "Test GPT: $test"

Output:

Error: unauthorized
{"error":{"code":"unauthorized","message":"Resource not accessible by integration","details":"Resource not accessible by integration"}}
@garman
Copy link
Contributor

garman commented Jan 28, 2025

Hi there! Thanks for the report.

Is there a permission that we can set to enable it?

There is not currently a permission that will enable seamless access to GitHub Models via Actions. Accessing models from a workflow is possible using a combination of Actions secrets and the gh auth login.

  • Create a personal access token
  • Store it as an Actions secret
  • Use gh auth login --with-token to login using the repository secret

A possible alternative could be using a GitHub app that has the right permissions, and use https://github.com/actions/create-github-app-token to access a token for the workflow, instead of using the default ${{ github.token }}.

Thanks for using Models!

@elyonz elyonz closed this as completed Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants