71 lines
1.8 KiB
Markdown

# Patch Odoo Ticket Gitea Action
Update an Odoo ticket via a FastAPI middleware whenever a Gitea Issue is created/updated/closed.
This action reads details from the issue event context and POSTs a JSON payload to your FastAPI endpoint at `/api/v1/patch_gitea_odoo`. The FastAPI service is responsible for talking to Odoo via JSON-RPC.
---
## What it sends
The action builds a JSON array with a single object from the issue event:
```json
[
{
"task_id": 123,
"state": "open",
"assignees": ["alice", "bob"],
"date_deadline": "2025-05-06"
}
]
```
- `task_id`: from `${{ gitea.event.issue.number }}`
- `state`: from `${{ gitea.event.issue.state }}` ("open" or "closed")
- `author`: from `${{ gitea.event.issue.user.login }}`
- `assignees`: from `${{ join(gitea.event.issue.assignees.*.login, ',') }}` (expanded and split)
- `labels`: from `${{ join(gitea.event.issue.labels.*.name, ',') }}` (expanded and split)
- `date_deadline`: from `${{ gitea.event.issue.due_date }}` if present
---
## Inputs
- `base_url` (required): Base URL of your FastAPI server, e.g. `https://fastapi.example.com`.
---
## Usage
Trigger on the events you care about (edit, labeled, closed, etc.). Example:
```yaml
name: Sync Odoo ticket
on:
issues:
types: [edited, closed, reopened, assigned, unassigned, labeled, unlabeled]
jobs:
patch-odoo:
runs-on: ubuntu-latest
steps:
- name: Send update to Odoo via FastAPI
uses: https://gitea.ethumada.com/gitea/patch-odoo-ticket
with:
base_url: ${{ vars.FASTAPI_BASE_URL }}
```
Secrets/variables:
- Set `FASTAPI_BASE_URL` secret to your FastAPI base URL.
---
## FastAPI endpoint contract
- Method: POST
- URL: `{base_url}/api/v1/patch_gitea_odoo`
- Body: JSON array of one or more objects as above
- Return: 2xx on success, any body will be logged for debugging