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