The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { Input } from "alchemy/Input"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import type { Environment } from "./Environment.ts"; |
| 4 | import { Variable } from "./Variable.ts"; |
| 5 | |
| 6 | export interface VariablesProps { |
| 7 | /** |
| 8 | * Repository owner (user or organization). |
| 9 | */ |
| 10 | owner: string; |
| 11 | |
| 12 | /** |
| 13 | * Repository name. |
| 14 | */ |
| 15 | repository: string; |
| 16 | |
| 17 | /** |
| 18 | * Optional environment. When set every variable is scoped to that GitHub |
| 19 | * Actions environment instead of the whole repository. Accepts an |
| 20 | * environment name or a `GitHub.Environment` resource. |
| 21 | */ |
| 22 | environment?: string | Environment; |
| 23 | |
| 24 | /** |
| 25 | * Map of variable name to value. Each entry becomes one |
| 26 | * `GitHub.Variable` resource, using the map key as both the alchemy |
| 27 | * logical id and the variable name. |
| 28 | */ |
| 29 | variables: Record<string, Input<string>>; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Bulk-creates a set of {@link Variable}s in the same repository. |
| 34 | * |
| 35 | * Plural counterpart of {@link import("./Secrets.ts").Secrets}, for |
| 36 | * non-sensitive values like region names, role ARNs, environment labels, |
| 37 | * or feature flags. |
| 38 | * **Example:** Example |
| 39 | * ```ts |
| 40 | * yield* GitHub.Variables({ |
| 41 | * owner: "my-org", |
| 42 | * repository: "my-repo", |
| 43 | * variables: { |
| 44 | * AWS_ROLE_ARN: role.roleArn, |
| 45 | * AWS_REGION: region, |
| 46 | * }, |
| 47 | * }); |
| 48 | * ``` |
| 49 | * |
| 50 | * @resource |
| 51 | * @product Actions |
| 52 | */ |
| 53 | export const Variables = ({ owner, repository, environment, variables }: VariablesProps) => |
| 54 | Effect.forEach(Object.entries(variables), ([name, value]) => |
| 55 | Variable(name, { |
| 56 | owner, |
| 57 | repository, |
| 58 | environment, |
| 59 | name, |
| 60 | value, |
| 61 | }), |
| 62 | ); |