g1t/packages/contracts/src/actions.ts
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[]; | |
| Actions: reusable workflows in the repository | 84 | /** `calling`: running the reusable workflow it calls, whose jobs follow it. */ |
| 85 | status: "waiting" | "queued" | "in_progress" | "calling" | "completed"; | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 86 | conclusion: Conclusion | null; |
| 87 | steps: StepState[]; | |
| 88 | annotations: Annotation[]; | |
| 89 | reason: string | null; | |
| 90 | startedAt: string | null; | |
| 91 | finishedAt: string | null; | |
| 92 | }; | |
| 93 | ||
| 94 | export type RunDetail = { run: WorkflowRun; jobs: Job[]; notes: WorkflowNote[] }; | |
| 95 | ||
| 96 | export type LogChunk = { seq: number; step: number; text: string }; | |
| 97 | export type JobLog = { chunks: LogChunk[]; done: boolean }; | |
| 98 | ||
| Secrets and variables: one list, rows per environment, for workflows and deployments | 99 | /** |
| 100 | * Who may read a secret or variable: `workflows` (`secrets.*`, `vars.*` in | |
| 101 | * GitHub Actions) and `deployments` (a deploy build's environment and the | |
| 102 | * running app's bindings). Agents, checks and the merge queue never read | |
| 103 | * any. | |
| 104 | */ | |
| 105 | export type SettingReader = "workflows" | "deployments"; | |
| 106 | ||
| 107 | /** | |
| 108 | * One row of secrets and variables, as Vercel lists environment variables: | |
| 109 | * a key, its type, the environments it applies to and who reads it. A key | |
| 110 | * may have one row per environment. Secrets' values are never returned. | |
| 111 | */ | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 112 | export type Setting = { |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 113 | id: string; |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 114 | name: string; |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 115 | /** `variable` is shown as Config. Config may become a secret, never back. */ |
| 116 | kind: SettingKind; | |
| 117 | /** A variable's value. */ | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 118 | value: string | null; |
| Projects: what a workspace builds and runs, first on every page | 119 | /** A project's (a repository's belong to its project) or the workspace's. */ |
| 120 | scope: "project" | "workspace"; | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 121 | updatedAt: string; |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 122 | availableTo: SettingReader[]; |
| 123 | /** The environments it applies to; empty is every environment. */ | |
| 124 | environments: string[]; | |
| Projects: what a workspace builds and runs, first on every page | 125 | /** A workspace's row: the projects it reaches, by slug; empty is every one. */ |
| 126 | projects: string[]; | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 127 | /** Where to rotate it, or who to ask. */ |
| 128 | note: string | null; | |
| 129 | updatedBy: string | null; | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 130 | }; |
| 131 | ||
| Secrets and variables: one list, rows per environment, for workflows and deployments | 132 | /** What saving a row sets beyond its value; left out is unchanged. */ |
| 133 | export type SettingOptions = { | |
| 134 | /** The row to change; left out, the key's row for every environment. */ | |
| 135 | id?: string; | |
| 136 | availableTo?: SettingReader[]; | |
| 137 | environments?: string[]; | |
| Projects: what a workspace builds and runs, first on every page | 138 | /** A workspace's row: project slugs; empty for every one. */ |
| 139 | projects?: string[]; | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 140 | note?: string; |
| 141 | }; | |
| 142 | ||
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 143 | export type SettingsOwner = { repo: RepoPath } | { workspace: string }; |
| 144 | export type SettingKind = "secret" | "variable"; | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 145 | /** `all` lists both. */ |
| 146 | export type SettingKindFilter = SettingKind | "all"; | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 147 | |
| 148 | export type RunsFilter = { | |
| 149 | workflow?: string; | |
| 150 | branch?: string; | |
| 151 | event?: string; | |
| 152 | pull?: number; | |
| 153 | sha?: string; | |
| 154 | limit?: number; | |
| 155 | }; | |
| 156 | ||
| 157 | export interface ActionsApi { | |
| 158 | workflows(repo: RepoPath, viewer: Viewer): Promise<Result<Workflow[]>>; | |
| 159 | runs(repo: RepoPath, viewer: Viewer, filter?: RunsFilter): Promise<Result<WorkflowRun[]>>; | |
| 160 | run(repo: RepoPath, viewer: Viewer, id: string): Promise<Result<RunDetail>>; | |
| 161 | logs(repo: RepoPath, viewer: Viewer, job: string, after?: number): Promise<Result<JobLog>>; | |
| 162 | dispatch( | |
| 163 | actor: User, | |
| 164 | repo: RepoPath, | |
| 165 | workflow: string, | |
| 166 | ref: string | undefined, | |
| 167 | inputs: Record<string, unknown>, | |
| 168 | ): Promise<Result<WorkflowRun>>; | |
| 169 | cancel(actor: User, repo: RepoPath, id: string): Promise<Result<WorkflowRun>>; | |
| 170 | rerun(actor: User, repo: RepoPath, id: string, failedOnly?: boolean): Promise<Result<WorkflowRun>>; | |
| 171 | setWorkflowEnabled(actor: User, repo: RepoPath, workflow: string, enabled: boolean): Promise<Result<Workflow>>; | |
| Secrets and variables: one list, rows per environment, for workflows and deployments | 172 | settings(actor: User, owner: SettingsOwner, kind: SettingKindFilter): Promise<Result<Setting[]>>; |
| 173 | /** `value` null keeps an existing entry's default value. */ | |
| 174 | setSetting( | |
| 175 | actor: User, | |
| 176 | owner: SettingsOwner, | |
| 177 | kind: SettingKind, | |
| 178 | name: string, | |
| 179 | value: string | null, | |
| 180 | options?: SettingOptions, | |
| 181 | ): Promise<Result<Setting>>; | |
| 182 | /** One row by `id`, or every row of the key. */ | |
| 183 | deleteSetting(actor: User, owner: SettingsOwner, kind: SettingKindFilter, name: string, id?: string): Promise<Result<boolean>>; | |
| GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs | 184 | } |