# Forgejo (Gitea) - pipe.gohorsejobs.com

Instância Forgejo self-hosted para mirror e CI/CD do projeto GoHorseJobs.

## Informacoes do Servico

| Campo | Valor |
|-------|-------|
| URL | https://pipe.gohorsejobs.com |
| Usuario | yamamoto (admin) |
| Email | yamamoto@rede5.com.br |
| Organizacao | bohessefm |
| Token | `~/.ssh/forgejo-token` |

## Autenticacao

### API Token
```bash
TOKEN=$(cat ~/.ssh/forgejo-token | grep FORGEJO_TOKEN | cut -d= -f2)
curl -H "Authorization: token $TOKEN" "https://pipe.gohorsejobs.com/api/v1/user"
```

### SSH
```bash
git clone git@pipe.gohorsejobs.com:bohessefm/gohorsejobs.git
```

## Repositorios

| Repositorio | Mirror de | Branch Principal |
|-------------|-----------|------------------|
| bohessefm/gohorsejobs | github.com/rede5/gohorsejobs | dev |

## CI/CD

O Forgejo roda workflows do `.forgejo/workflows/` para:
- Build e push de imagens Docker
- Deploy no K3s via kubectl

### Secrets e Variables

Configurados em Settings → Secrets and Variables:

**Secrets:**
- `FORGEJO_TOKEN` - Token de acesso ao registry
- `KUBE_CONFIG` - Configuracao kubectl
- `RSA_PRIVATE_KEY_BASE64` - Chave RSA privada

**Variables:**
- `DATABASE_URL` - String de conexao PostgreSQL
- `AMQP_URL` - URL RabbitMQ
- `JWT_SECRET` - Secret JWT
- `S3_BUCKET`, `AWS_*` - Credenciais S3

## API Endpoints

### Usuario
```bash
curl -H "Authorization: token $TOKEN" "https://pipe.gohorsejobs.com/api/v1/user"
```

### Repositorios
```bash
curl -H "Authorization: token $TOKEN" "https://pipe.gohorsejobs.com/api/v1/user/repos"
curl -H "Authorization: token $TOKEN" "https://pipe.gohorsejobs.com/api/v1/repos/bohessefm/gohorsejobs"
```

### Issues
```bash
curl -H "Authorization: token $TOKEN" "https://pipe.gohorsejobs.com/api/v1/repos/bohessefm/gohorsejobs/issues"
```

### Webhooks
```bash
# Listar webhooks
curl -H "Authorization: token $TOKEN" "https://pipe.gohorsejobs.com/api/v1/repos/bohessefm/gohorsejobs/hooks"

# Criar webhook
curl -X POST -H "Authorization: token $TOKEN" \
  -H "Content-Type: application/json" \
  "https://pipe.gohorsejobs.com/api/v1/repos/bohessefm/gohorsejobs/hooks" \
  -d '{
    "type": "gitea",
    "config": {
      "url": "https://redbull.rede5.com.br/api/v1/webhooks/deploy?uuid=iw4sow8s0kkg4cccsk08gsoo",
      "content_type": "json"
    },
    "events": ["push"],
    "active": true
  }'
```

## Docker Registry

O Forgejo inclui um registry Docker integrado:

```bash
# Login
echo $TOKEN | docker login pipe.gohorsejobs.com -u bohessefm --password-stdin

# Pull imagem
docker pull pipe.gohorsejobs.com/bohessefm/gohorsejobs:latest
docker pull pipe.gohorsejobs.com/bohessefm/backoffice:latest
```

## Links

- Console: https://pipe.gohorsejobs.com
- API Docs: https://pipe.gohorsejobs.com/api/swagger
- Credenciais: `~/.ssh/forgejo-token`
