sourcebot/docs/docs/connections/gitea.mdx
2025-11-04 21:22:31 -08:00

131 lines
No EOL
3.5 KiB
Text

---
title: Linking code from Gitea
sidebarTitle: Gitea
icon: mug-tea
---
import GiteaSchema from '/snippets/schemas/v3/gitea.schema.mdx'
Sourcebot can sync code from Gitea Cloud, and self-hosted.
If you're not familiar with Sourcebot [connections](/docs/connections/overview), please read that overview first.
## Examples
<AccordionGroup>
<Accordion title="Sync individual repos">
```json
{
"type": "gitea",
"repos": [
"sourcebot-dev/sourcebot",
"getsentry/sentry",
"torvalds/linux"
]
}
```
</Accordion>
<Accordion title="Sync all repos in a organization">
```json
{
"type": "gitea",
"orgs": [
"sourcebot-dev",
"getsentry",
"vercel"
]
}
```
</Accordion>
<Accordion title="Sync all repos owned by a user">
```json
{
"type": "gitea",
"users": [
"torvalds",
"ggerganov"
]
}
```
</Accordion>
<Accordion title="Exclude repos from syncing">
```json
{
"type": "gitea",
// Include all repos in my-org...
"orgs": [
"my-org"
],
// ...except:
"exclude": {
// repos that are archived
"archived": true,
// repos that are forks
"forks": true,
// repos that match these glob patterns
"repos": [
"my-org/repo1",
"my-org/repo2",
"my-org/sub-org-1/**",
"my-org/sub-org-*/**"
]
}
}
```
</Accordion>
</AccordionGroup>
## Authenticating with Gitea
In order to index private repositories, you'll need to generate a Gitea access token. Generate a Gitea access token [here](http://gitea.com/user/settings/applications). At minimum, you'll need to select the `read:repository` scope. `read:user` and `read:organization` are required for the `user` and `org` fields of your config file:
![Gitea Access token creation](/images/gitea_pat_creation.png)
Next, provide the access token via an environment variable [token](/docs/configuration/config-file#tokens) which is referenced in the `token` property:
<Tabs>
<Tab title="Environment Variable">
1. Add the `token` property to your connection config:
```json
{
"type": "gitea",
"token": {
// note: this env var can be named anything. It
// doesn't need to be `GITEA_TOKEN`.
"env": "GITEA_TOKEN"
}
// .. rest of config ..
}
```
2. Pass this environment variable each time you run Sourcebot:
```bash
docker run \
-e GITEA_TOKEN=<PAT> \
/* additional args */ \
ghcr.io/sourcebot-dev/sourcebot:latest
```
</Tab>
</Tabs>
## Connecting to a custom Gitea
To connect to a custom Gitea deployment, provide the `url` property to your config:
```json
{
"type": "gitea",
"url": "https://gitea.example.com"
// .. rest of config ..
}
```
## Schema reference
<Accordion title="Reference">
[schemas/v3/gitea.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/gitea.json)
<GiteaSchema />
</Accordion>