154 lines
4.4 KiB
Markdown
154 lines
4.4 KiB
Markdown
# Gitea Actions
|
|
|
|
Repository contenente action [Gitea Actions](https://docs.gitea.com/usage/actions/overview) centralizzate
|
|
utilizzabili da altri repository del workspace.
|
|
|
|
## Action disponibili
|
|
|
|
### `install-opencode`
|
|
|
|
Installa [OpenCode](https://opencode.ai) globalmente via npm. Verifica la presenza di Node.js e npm,
|
|
installando npm automaticamente su Alpine se mancante.
|
|
|
|
```yaml
|
|
- uses: https://<host>/<owner>/Actions/install-opencode@<ref>
|
|
# with:
|
|
# version: "1.15.0" # fissa una versione specifica
|
|
```
|
|
|
|
### `opencode-prompt`
|
|
|
|
Esegue un prompt OpenCode sul codice del repository. Richiede che `install-opencode`
|
|
sia eseguito prima, oppure che OpenCode sia già presente sul runner.
|
|
|
|
```yaml
|
|
- id: ai
|
|
uses: https://<host>/<owner>/Actions/opencode-prompt@<ref>
|
|
with:
|
|
prompt: "Analizza il codice e trova potenziali bug"
|
|
api-key: ${{ secrets.OPENCODE_API_KEY }}
|
|
# opzionali:
|
|
model: "deepseek/deepseek-v4-flash" # default
|
|
agent: "" # agente opencode
|
|
working-directory: "" # default: radice repo
|
|
```
|
|
|
|
L'output `result` contiene la risposta di OpenCode e viene salvato anche in
|
|
`$GITHUB_WORKSPACE/opencode-output.txt`.
|
|
|
|
### `triage-issue`
|
|
|
|
Analizza automaticamente le issue in apertura con OpenCode: classifica come **bug** o
|
|
**richiesta**, produce un riassunto, una gap analisi rispetto al codice sorgente, domande
|
|
aperte e un report tecnico dettagliato in formato Markdown caricato come asset.
|
|
|
|
#### Utilizzo
|
|
|
|
```yaml
|
|
- uses: https://<host>/<owner>/Actions/triage-issue@<ref>
|
|
with:
|
|
issue-title: ${{ github.event.issue.title }}
|
|
issue-body: ${{ github.event.issue.body }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
repository: ${{ github.repository }}
|
|
api-token: ${{ secrets.TOKEN }}
|
|
api-key: ${{ secrets.OPENCODE_API_KEY }}
|
|
# opzionali:
|
|
model: "deepseek/deepseek-v4-flash" # default
|
|
gitea-host: "https://git.incloud.ovh" # default
|
|
```
|
|
|
|
#### Prerequisiti nel repository target
|
|
|
|
1. **Secrets**: `TOKEN` (API Gitea), `OPENCODE_API_KEY` (API AI)
|
|
2. **Label**: `bug` (rosso `dc3545`) e `richiesta` (blu `007bff`)
|
|
3. **Workflow** (esempio `.gitea/workflows/triage.yml`):
|
|
|
|
```yaml
|
|
name: Triage Issue
|
|
on:
|
|
issues:
|
|
types: [opened]
|
|
jobs:
|
|
triage:
|
|
runs-on: linux_amd64
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: https://git.incloud.ovh/anuti/Actions/install-opencode@main
|
|
- uses: https://git.incloud.ovh/anuti/Actions/triage-issue@main
|
|
with:
|
|
issue-title: ${{ github.event.issue.title }}
|
|
issue-body: ${{ github.event.issue.body }}
|
|
issue-number: ${{ github.event.issue.number }}
|
|
repository: ${{ github.repository }}
|
|
api-token: ${{ secrets.TOKEN }}
|
|
api-key: ${{ secrets.OPENCODE_API_KEY }}
|
|
```
|
|
|
|
#### Output
|
|
|
|
- **Label** `bug` o `richiesta` applicata sull'issue
|
|
- **Commento** con riassunto, gap analisi e domande aperte
|
|
- **Asset Markdown** (`triage-issue-N.md`) con analisi tecnica completa, linkato nel commento
|
|
|
|
---
|
|
|
|
### `version-from-tag`
|
|
|
|
Estrae la versione da un tag (formato `v1.2.3.4[-suffix]`) e produce le variabili
|
|
`appver`, `fullver`, `suffix` e `version`.
|
|
|
|
```yaml
|
|
- name: Calcola versione
|
|
uses: https://<host>/<owner>/Actions/version-from-tag@<ref>
|
|
with:
|
|
ref-name: ${{ github.ref_name }}
|
|
```
|
|
|
|
### `publish-dotnet`
|
|
|
|
Compila (restore + publish) un progetto .NET e sincronizza l'output su un path
|
|
locale via `rsync`.
|
|
|
|
```yaml
|
|
- name: Publish
|
|
uses: https://<host>/<owner>/Actions/publish-dotnet@<ref>
|
|
with:
|
|
project: src/MyApp/MyApp.csproj
|
|
output-path: /var/publish/myapp
|
|
version: ${{ steps.versione.outputs.appver }}
|
|
# opzionali:
|
|
configuration: Release
|
|
subpath: "wwwroot"
|
|
exclude-dirs: store
|
|
exclude-files: appsettings.json
|
|
```
|
|
|
|
### `deploy-iis`
|
|
|
|
Esegue il deploy su IIS: ferma sito/application pool, copia i file via `robocopy`,
|
|
riavvia i servizi.
|
|
|
|
```yaml
|
|
- name: Deploy IIS
|
|
uses: https://<host>/<owner>/Actions/deploy-iis@<ref>
|
|
with:
|
|
source-path: /var/publish/myapp
|
|
destination-path: C:\inetpub\wwwroot\myapp
|
|
site-name: MySite
|
|
app-pool-name: MyAppPool
|
|
exclude-dirs: store
|
|
exclude-files: appsettings.json
|
|
```
|
|
|
|
## Versionamento delle action
|
|
|
|
Per puntare a una versione stabile, crea un tag su questo repository
|
|
(es. `v1.0.0`) e usalo nel riferimento:
|
|
|
|
```yaml
|
|
uses: https://<host>/<owner>/Actions/publish-dotnet@v1.0.0
|
|
```
|
|
|
|
Oppure punta a un branch (`@main`) per avere sempre l'ultima versione.
|