Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 1 | import type { User, Viewer } from "./identity"; |
| 2 | import type { RepoPath } from "./repos"; | |
| 3 | import type { Result } from "./result"; | |
| 4 | ||
| 5 | /** | |
| 6 | * GitHub Actions workflows, run on g1t as they are. Mirrors | |
| 7 | * `crates/contracts/src/actions.rs`. | |
| 8 | */ | |
| 9 | ||
| 10 | export type WorkflowNote = { | |
| 11 | severity: "info" | "warning" | "unsupported"; | |
| 12 | job: string | null; | |
| 13 | message: string; | |
| 14 | }; | |
| 15 | ||
| 16 | /** One `workflow_dispatch` input, as written in the workflow. */ | |
| 17 | export type DispatchInput = { | |
| 18 | description?: string; | |
| 19 | required?: boolean; | |
| 20 | default?: string | number | boolean; | |
| 21 | type?: "string" | "boolean" | "number" | "choice" | "environment"; | |
| 22 | options?: string[]; | |
| 23 | }; | |
| 24 | ||
| 25 | export type RunStatus = "pending" | "queued" | "in_progress" | "completed"; | |
| 26 | export type Conclusion = "success" | "failure" | "cancelled" | "skipped"; | |
| 27 | ||
| 28 | export type WorkflowRun = { | |
| 29 | id: string; | |
| 30 | workflowId: string; | |
| 31 | path: string; | |
| 32 | name: string; | |
| 33 | title: string; | |
| 34 | number: number; | |
| 35 | attempt: number; | |
| 36 | event: string; | |
| 37 | ref: string; | |
| 38 | sha: string; | |
| 39 | pull: number | null; | |
| 40 | status: RunStatus; | |
| 41 | conclusion: Conclusion | null; | |
| 42 | error: string | null; | |
| 43 | actor: string | null; | |
| 44 | createdAt: string; | |
| 45 | startedAt: string | null; | |
| 46 | finishedAt: string | null; | |
| 47 | }; | |
| 48 | ||
| 49 | export type Workflow = { | |
| 50 | id: string; | |
| 51 | path: string; | |
| 52 | name: string; | |
| 53 | events: string[]; | |
| 54 | state: "active" | "disabled"; | |
| 55 | error: string | null; | |
| 56 | notes: WorkflowNote[]; | |
| 57 | dispatch: Record<string, DispatchInput> | null; | |
| 58 | lastRun: WorkflowRun | null; | |
| 59 | }; | |
| 60 | ||
| 61 | export type StepState = { | |
| 62 | number: number; | |
| 63 | name: string; | |
| 64 | status: "queued" | "in_progress" | "completed"; | |
| 65 | conclusion: Conclusion | null; | |
| 66 | startedAt: string | null; | |
| 67 | finishedAt: string | null; | |
| 68 | }; | |
| 69 | ||
| 70 | export type Annotation = { | |
| 71 | level: "error" | "warning" | "notice"; | |
| 72 | message: string; | |
| 73 | title: string | null; | |
| 74 | file: string | null; | |
| 75 | line: number | null; | |
| 76 | }; | |
| 77 | ||
| 78 | export type Job = { | |
| 79 | id: string; | |
| 80 | runId: string; | |
| 81 | key: string; | |
| 82 | name: string; | |
| 83 | needs: string[]; | |
| 84 | status: "waiting" | "queued" | "in_progress" | "completed"; | |
| 85 | conclusion: Conclusion | null; | |
| 86 | steps: StepState[]; | |
| 87 | annotations: Annotation[]; | |
| 88 | reason: string | null; | |
| 89 | startedAt: string | null; | |
| 90 | finishedAt: string | null; | |
| 91 | }; | |
| 92 | ||
| 93 | export type RunDetail = { run: WorkflowRun; jobs: Job[]; notes: WorkflowNote[] }; | |
| 94 | ||
| 95 | export type LogChunk = { seq: number; step: number; text: string }; | |
| 96 | export type JobLog = { chunks: LogChunk[]; done: boolean }; | |
| 97 | ||
| 98 | export type Setting = { | |
| 99 | name: string; | |
| 100 | /** Variables only. */ | |
| 101 | value: string | null; | |
| 102 | scope: "repository" | "workspace"; | |
| 103 | updatedAt: string; | |
| 104 | }; | |
| 105 | ||
| 106 | export type SettingsOwner = { repo: RepoPath } | { workspace: string }; | |
| 107 | export type SettingKind = "secret" | "variable"; | |
| 108 | ||
| 109 | export type RunsFilter = { | |
| 110 | workflow?: string; | |
| 111 | branch?: string; | |
| 112 | event?: string; | |
| 113 | pull?: number; | |
| 114 | sha?: string; | |
| 115 | limit?: number; | |
| 116 | }; | |
| 117 | ||
| 118 | export interface ActionsApi { | |
| 119 | workflows(repo: RepoPath, viewer: Viewer): Promise<Result<Workflow[]>>; | |
| 120 | runs(repo: RepoPath, viewer: Viewer, filter?: RunsFilter): Promise<Result<WorkflowRun[]>>; | |
| 121 | run(repo: RepoPath, viewer: Viewer, id: string): Promise<Result<RunDetail>>; | |
| 122 | logs(repo: RepoPath, viewer: Viewer, job: string, after?: number): Promise<Result<JobLog>>; | |
| 123 | dispatch( | |
| 124 | actor: User, | |
| 125 | repo: RepoPath, | |
| 126 | workflow: string, | |
| 127 | ref: string | undefined, | |
| 128 | inputs: Record<string, unknown>, | |
| 129 | ): Promise<Result<WorkflowRun>>; | |
| 130 | cancel(actor: User, repo: RepoPath, id: string): Promise<Result<WorkflowRun>>; | |
| 131 | rerun(actor: User, repo: RepoPath, id: string, failedOnly?: boolean): Promise<Result<WorkflowRun>>; | |
| 132 | setWorkflowEnabled(actor: User, repo: RepoPath, workflow: string, enabled: boolean): Promise<Result<Workflow>>; | |
| 133 | settings(actor: User, owner: SettingsOwner, kind: SettingKind): Promise<Result<Setting[]>>; | |
| 134 | setSetting(actor: User, owner: SettingsOwner, kind: SettingKind, name: string, value: string): Promise<Result<Setting>>; | |
| 135 | deleteSetting(actor: User, owner: SettingsOwner, kind: SettingKind, name: string): Promise<Result<boolean>>; | |
| 136 | } |