Skip to main content

GitHub

Give your agent access to GitHub — reading issues, creating pull requests, cloning repos, and more. Credentials are injected by the Pai sidecar; the agent never holds the real token.

Get a token

  1. Go to github.com/settings/tokens
  2. Click Generate new token (classic)
  3. Select scopes: repo (full repo access) or narrow it down as needed
  4. Copy the token — it starts with ghp_

Setup

# 1. Store the token
pai add secret github-pat --from-literal token=ghp_...

# 2. Create the provider
pai apply -f - <<EOF
apiVersion: pai.io/v1
kind: Provider
metadata:
name: github-writer
spec:
type: github
auth:
type: pat
secretRef: github-pat
policy:
allow:
- pulls:create
- pulls:comment
- issues:read
- issues:comment
- contents:read
deny:
- admin:*
- repo:delete
scope:
repositories:
- "myorg/my-repo"
EOF

Attach to an agent

spec:
providers:
- github-writer

Supported actions

ActionAPI operations
contents:readRead files, clone repo, git fetch/pull
contents:writePush commits, git push
pulls:readList and read pull requests
pulls:createOpen a new pull request
pulls:commentComment on pull requests
pulls:updateUpdate PR title, body, labels
issues:readList and read issues
issues:createOpen a new issue
issues:commentComment on issues
repo:readRead repository metadata
repo:deleteDelete a repository
org:readRead organization info
org:updateUpdate organization settings
admin:collaboratorsAdd or remove collaborators

Scope — restricting to specific repos

scope:
repositories:
- "myorg/repo-a"
- "myorg/repo-b"

Requests to any repository not in this list are denied, even if the action is allowed by policy.

Read-only example

spec:
type: github
auth:
type: pat
secretRef: github-pat
policy:
allow: ["*"]
httpRules:
- methods: [GET]
paths: ["*"]
effect: allow
- methods: [POST, PUT, PATCH, DELETE]
paths: ["*"]
effect: deny