Docs / Get started
On this page
Connect GitHub
Kajiya needs two things in a repository: to see when a job with a Kajiya label is queued, and to register a one-time runner for that job. You can grant this with the Kajiya CI GitHub App (recommended) or with a fine-grained personal access token.
| GitHub App | Fine-grained token | |
|---|---|---|
| Setup | One button in the dashboard; pick repositories on GitHub | Create a token on GitHub and paste it |
| Repository list | Follows the installation: repositories you add or remove on GitHub are connected or disconnected | You connect each repository, a list or an organization |
| Expiry | Does not expire; Kajiya uses short-lived installation tokens | Expires when you chose; you replace it |
| How Kajiya hears about jobs | The App's workflow_job events, within seconds | A repository webhook if the token may create one, otherwise polling |
Install the Kajiya CI GitHub App#
- In the dashboard, choose Install GitHub App. The App is called Kajiya CI (github.com/apps/kajiya-ci); start from the dashboard so the installation is linked to your account.
- GitHub asks where to install it: your personal account or an organization you own. Choose All repositories or Only select repositories.
- GitHub asks you to authorize Kajiya. This lets Kajiya confirm, with GitHub, that your GitHub account can access the installation; Kajiya never trusts an installation id from a redirect alone.
- You return to the dashboard. The repositories you selected appear under Repositories, already connected.
If you are a member but not an owner of an organization, GitHub sends the owners an installation request instead. Once an owner approves it, open the dashboard and choose Link an existing installation.
What the App can do#
| Permission | Access | What Kajiya uses it for |
|---|---|---|
| Administration | Read and write | Register a one-time (just-in-time) self-hosted runner for each job |
| Actions | Read and write | Read queued workflow jobs; cancel a run when you cancel a job in Kajiya |
| Metadata | Read | Required by GitHub for every App: repository names and basic information |
The App receives three kinds of events: workflow_job (a job was queued or finished, so Kajiya can start it within seconds or release a runner it no longer needs), and installation and installation_repositories (so the connected repositories follow the installation).
The App has no access to your code, issues, pull requests or secrets. Your workflow checks out code inside the job's VM with its own GITHUB_TOKEN, as on any runner.
Change repositories or remove the App#
Repository access is managed on GitHub: Settings → Applications → Installed GitHub Apps → Configure for a personal account, or the organization's Settings → GitHub Apps. Repositories you add there are connected in Kajiya; repositories you remove are disconnected. Uninstalling or suspending the App disconnects all of its repositories at once. Job history stays in Kajiya.
You can also unlink an installation in the dashboard. Kajiya then stops using it, but the App stays installed on GitHub until an owner removes it there.
A repository connected with a token moves to the App when the App is installed on it, and Kajiya deletes the repository webhook it had created for the token.
Connect with a fine-grained token#
- On GitHub, open Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token.
- Resource owner: your account, or the organization that owns the repositories. Organizations can require an owner to approve fine-grained tokens before they work.
- Expiration: your choice. When the token expires, Kajiya can no longer see the queue until you replace it.
- Repository access: Only select repositories (recommended) or All repositories.
- Repository permissions: set the three below. GitHub adds Metadata: Read by itself.
- Generate the token, then paste it in the dashboard under Repositories → Connect repositories.
| Permission | Needed | What Kajiya uses it for | Without it |
|---|---|---|---|
| Administration: Read and write | Required | Confirm you administer the repository, and register a one-time runner for each job | The repository cannot be connected |
| Webhooks: Read and write | Recommended | Create a repository webhook for workflow_job events, so jobs start within seconds | Kajiya polls: every 10 s while the repository is busy, every 60 s when idle |
| Actions: Read and write | Recommended | Read: list queued jobs (polling, and a safety-net check every 5 minutes on webhook repositories). Write: cancel runs from Kajiya | Jobs start only from webhook events, and cancelling from Kajiya fails |
The token is stored encrypted on Kajiya's control server and is never sent to a job VM. Each VM only receives a one-time runner registration.
Connect many repositories at once#
The dashboard's Connect repositories form has three modes: One repository, a List (one per line, up to 200), or an Organization (leave the name empty to connect everything the token administers). Through the API:
# every repository of an organization that the token administers
curl -X POST "https://kajiya.app/api/v1/repos" \
-H "Authorization: Bearer $KAJIYA_API_KEY" -H "Content-Type: application/json" \
-d '{"github_token": "github_pat_...", "owner": "acme"}'
# an explicit list
curl -X POST "https://kajiya.app/api/v1/repos" \
-H "Authorization: Bearer $KAJIYA_API_KEY" -H "Content-Type: application/json" \
-d '{"github_token": "github_pat_...", "repos": ["acme/api", "acme/web"]}'
# everything the token administers
curl -X POST "https://kajiya.app/api/v1/repos" \
-H "Authorization: Bearer $KAJIYA_API_KEY" -H "Content-Type: application/json" \
-d '{"github_token": "github_pat_...", "all": true}'Each repository gets a result: connected, updated (it was already connected and now uses the new token), skipped (archived, or the token is not an admin there) or error with a message. Rules:
- One request handles up to 200 repositories. When an organization has more, the response says so; connect the rest with a
reposlist. owneris meant for organizations. For repositories of a personal account, send areposlist orall: true.- An account can have up to 500 connected repositories, and a repository belongs to one Kajiya account at a time.
Replace an expired token#
Connect the same repositories again with the new token, the same way you connected them. Each comes back as updated, and Kajiya uses the new token from then on. To check right away instead of waiting for the next poll, call POST /api/v1/repos/{id}/sync.
Revoke access#
- Disconnect a repository in the dashboard, or call
DELETE /api/v1/repos/{id}. Kajiya stops using its token and deletes the webhook it created, if the token still allows that. Job history stays. - Delete the token on GitHub (Settings → Developer settings → Fine-grained tokens) to make sure it can never be used again. Organization owners can also revoke fine-grained tokens that have access to the organization.
How Kajiya hears about jobs#
The dispatch field of GET /api/v1/repos, and the Repositories tab, show how each repository is watched:
dispatch | Meaning |
|---|---|
webhook | GitHub delivers workflow_job events (through the App, or the repository webhook). Jobs start within seconds. Kajiya also checks the queue every 5 minutes as a safety net. |
webhook_pending | The webhook exists but GitHub has not delivered an event yet. It turns into webhook on the first delivery. |
polling | No webhook. Kajiya checks every 10 s while the repository had a job in the last 30 minutes, every 60 s otherwise, and every 10 s while any of its jobs is waiting. dispatch_note says why the webhook is missing. |
If GitHub rate-limits Kajiya, polling for that repository backs off for 5 minutes.