feat(gitea): add Actions API support: list filters, run/job endpoints, dispatch, and richer types
This commit is contained in:
@@ -11,6 +11,7 @@ import type {
|
||||
IGiteaActionRunJob,
|
||||
ITestConnectionResult,
|
||||
IListOptions,
|
||||
IActionRunListOptions,
|
||||
} from './gitea.interfaces.js';
|
||||
|
||||
export class GiteaClient {
|
||||
@@ -259,30 +260,77 @@ export class GiteaClient {
|
||||
// Action Runs
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
public async getActionRuns(ownerRepo: string, opts?: IListOptions): Promise<IGiteaActionRun[]> {
|
||||
/**
|
||||
* List action runs for a repository with optional filters.
|
||||
* Supports status, branch, event, actor filtering.
|
||||
*/
|
||||
public async getActionRuns(ownerRepo: string, opts?: IActionRunListOptions): Promise<IGiteaActionRun[]> {
|
||||
const page = opts?.page || 1;
|
||||
const limit = opts?.perPage || 30;
|
||||
const body = await this.request<any>('GET', `/api/v1/repos/${ownerRepo}/actions/runs?page=${page}&limit=${limit}`);
|
||||
let url = `/api/v1/repos/${ownerRepo}/actions/runs?page=${page}&limit=${limit}`;
|
||||
if (opts?.status) url += `&status=${encodeURIComponent(opts.status)}`;
|
||||
if (opts?.branch) url += `&branch=${encodeURIComponent(opts.branch)}`;
|
||||
if (opts?.event) url += `&event=${encodeURIComponent(opts.event)}`;
|
||||
if (opts?.actor) url += `&actor=${encodeURIComponent(opts.actor)}`;
|
||||
const body = await this.request<any>('GET', url);
|
||||
return body.workflow_runs || body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single action run's full details.
|
||||
*/
|
||||
public async getActionRun(ownerRepo: string, runId: number): Promise<IGiteaActionRun> {
|
||||
return this.request<IGiteaActionRun>(
|
||||
'GET',
|
||||
`/api/v1/repos/${ownerRepo}/actions/runs/${runId}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List jobs for an action run.
|
||||
*/
|
||||
public async getActionRunJobs(ownerRepo: string, runId: number): Promise<IGiteaActionRunJob[]> {
|
||||
const body = await this.request<any>('GET', `/api/v1/repos/${ownerRepo}/actions/runs/${runId}/jobs`);
|
||||
return body.jobs || body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a job's raw log output.
|
||||
*/
|
||||
public async getJobLog(ownerRepo: string, jobId: number): Promise<string> {
|
||||
return this.requestText('GET', `/api/v1/repos/${ownerRepo}/actions/jobs/${jobId}/logs`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-run an action run.
|
||||
*/
|
||||
public async rerunAction(ownerRepo: string, runId: number): Promise<void> {
|
||||
await this.request('POST', `/api/v1/repos/${ownerRepo}/actions/runs/${runId}/rerun`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a running action run.
|
||||
*/
|
||||
public async cancelAction(ownerRepo: string, runId: number): Promise<void> {
|
||||
await this.request('POST', `/api/v1/repos/${ownerRepo}/actions/runs/${runId}/cancel`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a workflow (trigger manually).
|
||||
*/
|
||||
public async dispatchWorkflow(
|
||||
ownerRepo: string,
|
||||
workflowId: string,
|
||||
ref: string,
|
||||
inputs?: Record<string, string>,
|
||||
): Promise<void> {
|
||||
await this.request(
|
||||
'POST',
|
||||
`/api/v1/repos/${ownerRepo}/actions/workflows/${encodeURIComponent(workflowId)}/dispatches`,
|
||||
{ ref, inputs: inputs || {} },
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Repository Deletion
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user