@limetry/ci 1.2.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # `@limetry/ci`
2
+
3
+ > [!NOTE]
4
+ > **Origin:** A fork PR shared a workflow with `configure-aws-credentials`. No token was
5
+ > stolen. Untrusted code and credential steps ran in the same job (`pull_request_target`
6
+ > shape). `@limetry/ci` evaluates `ci_privilege` and `deploy` intents against a policy
7
+ > *before* credentials load.
8
+
9
+ GitHub Action and library helpers that evaluate CI privilege and deploy intents with Limetry
10
+ before a workflow uses secrets, OIDC, or production deploy credentials.
11
+
12
+ This repository uses two action policies:
13
+
14
+ | File | Allow | Deny | Used by |
15
+ | --- | --- | --- | --- |
16
+ | [`policies/ci-privilege.json`](policies/ci-privilege.json) | `ci_privilege` | `deploy` | [`.github/workflows/limetry-ci-gate.yml`](../../.github/workflows/limetry-ci-gate.yml) |
17
+ | [`policies/deploy.json`](policies/deploy.json) | `ci_privilege`, `deploy` | — | [`.github/workflows/deploy-infra.yml`](../../.github/workflows/deploy-infra.yml) |
18
+
19
+ `ci_privilege` is the test/typecheck lane. `deploy` is Pulumi / production publish.
20
+ `@limetry/ci` classifies GitHub events against an explicit trusted allowlist (`push`,
21
+ `release`, `workflow_dispatch`). Pull-request, review, issue, and `workflow_run` events
22
+ are untrusted, and any event not on the allowlist — including `schedule` — is untrusted
23
+ by default. Deploy jobs set `require_trusted: true` so fork PRs fail before AWS
24
+ credentials are loaded.
25
+
26
+ ## Live demo in this repo
27
+
28
+ [`.github/workflows/limetry-ci-gate.yml`](../../.github/workflows/limetry-ci-gate.yml)
29
+ starts a Limetry node in the job, applies `ci-privilege.json`, then:
30
+
31
+ 1. Evaluates `ci_privilege` — must **allow** (tests may run).
32
+ 2. Evaluates `deploy` — must **deny** and fail that step (`action_type deploy is denied`).
33
+
34
+ [`.github/workflows/deploy-infra.yml`](../../.github/workflows/deploy-infra.yml) applies
35
+ `deploy.json` and evaluates `deploy` with `require_trusted: true` **before**
36
+ `configure-aws-credentials`.
37
+
38
+ That workflow builds `@limetry/ci` from source. `dist/` is gitignored, so
39
+ `uses: limetry/limetry/packages/ci@main` cannot run `dist/run-action.js` from a raw checkout.
40
+
41
+ ## Install
42
+
43
+ The composite action currently requires a source checkout because `dist/` is gitignored.
44
+ For drop-in use, reference the monorepo path:
45
+
46
+ ```yaml
47
+ - uses: limetry/limetry/packages/ci@main
48
+ with:
49
+ limetry_api_key: ${{ secrets.LIMETRY_API_KEY }}
50
+ limetry_base_url: ${{ vars.LIMETRY_BASE_URL }}
51
+ policy_id: ${{ vars.LIMETRY_CI_POLICY_ID }}
52
+ action_type: deploy
53
+ require_trusted: "true"
54
+ ```
55
+
56
+ ## Apply the same rules on your evaluation server
57
+
58
+ ```bash
59
+ limetry setup
60
+ limetry policy apply --file packages/ci/policies/ci-privilege.json
61
+ limetry policy apply --file packages/ci/policies/deploy.json
62
+ ```
63
+
64
+ Then point a workflow at your Limetry node (see `packages/ci/examples/workflow.yml`).
65
+
66
+ `LIMETRY_CI_POLICY_ID` for production deploys is the `policy_id` inside `deploy.json`
67
+ (`22222222-2222-4222-8222-222222222222`) unless you apply a new UUID.
68
+
69
+ ## Library
70
+
71
+ ```ts
72
+ import { evaluateCiPrivilege, verifyReleaseReceipt } from "@limetry/ci"
73
+
74
+ const result = await evaluateCiPrivilege({
75
+ apiKey: process.env.LIMETRY_API_KEY!,
76
+ policyId: process.env.LIMETRY_POLICY_ID!,
77
+ agentId: "github_actions",
78
+ actionType: "deploy",
79
+ repository: "limetry/limetry",
80
+ sha: process.env.GITHUB_SHA!,
81
+ eventName: "push",
82
+ })
83
+ ```
84
+
85
+ The ActionIntent resource is `owner/repo@sha`. Policy evaluation stays in
86
+ `@limetry/sdk` / the Limetry server.
87
+
88
+ `evaluateCiPrivilege` resolves to `{ evaluation, intent, trust }`. Read the decision
89
+ from `result.evaluation.decision` and the event trust from `result.trust`.
package/action.yml ADDED
@@ -0,0 +1,78 @@
1
+ name: Limetry CI Privilege Gate
2
+ description: Evaluate CI privilege and deploy intents with Limetry before secrets or deploys
3
+ author: Limetry
4
+ branding:
5
+ icon: shield
6
+ color: orange
7
+ inputs:
8
+ limetry_base_url:
9
+ description: Limetry API base URL
10
+ required: false
11
+ default: https://api.limetry.com
12
+ limetry_api_key:
13
+ description: Limetry bearer token
14
+ required: true
15
+ policy_id:
16
+ description: ActionPolicy id for CI evaluate
17
+ required: true
18
+ agent_id:
19
+ description: Agent id recorded on the ActionIntent
20
+ required: false
21
+ default: github_actions
22
+ action_type:
23
+ description: ci_privilege or deploy
24
+ required: false
25
+ default: ci_privilege
26
+ require_trusted:
27
+ description: Fail when the GitHub event is untrusted (pull_request, issues, etc.)
28
+ required: false
29
+ default: "true"
30
+ fail_on_approval_required:
31
+ description: Fail the job when Limetry returns approval_required
32
+ required: false
33
+ default: "true"
34
+ package:
35
+ description: npm spec for @limetry/ci when dist/ is not in this checkout
36
+ required: false
37
+ default: "@limetry/ci@0.1.0"
38
+ outputs:
39
+ decision:
40
+ description: allow, deny, or approval_required
41
+ value: ${{ steps.evaluate.outputs.decision }}
42
+ approval_id:
43
+ description: Pending approval id when decision is approval_required
44
+ value: ${{ steps.evaluate.outputs.approval_id }}
45
+ decision_id:
46
+ description: Limetry decision id
47
+ value: ${{ steps.evaluate.outputs.decision_id }}
48
+ receipt_digest:
49
+ description: HMAC receipt digest bound to the evaluated intent
50
+ value: ${{ steps.evaluate.outputs.receipt_digest }}
51
+ runs:
52
+ using: composite
53
+ steps:
54
+ - name: Setup Node
55
+ uses: actions/setup-node@v5
56
+ with:
57
+ node-version: "22"
58
+
59
+ - name: Evaluate CI intent
60
+ id: evaluate
61
+ shell: bash
62
+ env:
63
+ INPUT_LIMETRY_API_KEY: ${{ inputs.limetry_api_key }}
64
+ INPUT_LIMETRY_BASE_URL: ${{ inputs.limetry_base_url }}
65
+ INPUT_POLICY_ID: ${{ inputs.policy_id }}
66
+ INPUT_AGENT_ID: ${{ inputs.agent_id }}
67
+ INPUT_ACTION_TYPE: ${{ inputs.action_type }}
68
+ INPUT_REQUIRE_TRUSTED: ${{ inputs.require_trusted }}
69
+ INPUT_FAIL_ON_APPROVAL_REQUIRED: ${{ inputs.fail_on_approval_required }}
70
+ LIMETRY_CI_PACKAGE: ${{ inputs.package }}
71
+ run: |
72
+ set -euo pipefail
73
+ ACTION_DIST="${GITHUB_ACTION_PATH}/dist/run-action.js"
74
+ if [ -f "$ACTION_DIST" ]; then
75
+ node "$ACTION_DIST"
76
+ else
77
+ npx --yes "$LIMETRY_CI_PACKAGE"
78
+ fi
@@ -0,0 +1,25 @@
1
+ /**
2
+ * GitHub Actions event trust classification for CI privilege gating.
3
+ *
4
+ * Distinguishes trusted workflow triggers (push, release, workflow_dispatch)
5
+ * from untrusted fork/PR-adjacent events that must not receive privileged secrets.
6
+ */
7
+ /**
8
+ * Whether a GitHub Actions event is trusted for privileged secrets.
9
+ */
10
+ export type EventTrust = "trusted" | "untrusted";
11
+ /**
12
+ * Classify whether a GitHub Actions event should receive privileged secrets.
13
+ *
14
+ * Returns `untrusted` for known PR/issue/workflow_run events, pull refs, and
15
+ * any unrecognized event name. Only `push`, `release`, and `workflow_dispatch`
16
+ * are trusted.
17
+ *
18
+ * @param input - Event name and optional git ref from the workflow context.
19
+ * @returns `"trusted"` or `"untrusted"`.
20
+ */
21
+ export declare function classifyEventTrust(input: {
22
+ eventName: string;
23
+ ref?: string;
24
+ }): EventTrust;
25
+ //# sourceMappingURL=classify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../src/classify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,CAAA;AAehD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,UAAU,CAYb"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * GitHub Actions event trust classification for CI privilege gating.
3
+ *
4
+ * Distinguishes trusted workflow triggers (push, release, workflow_dispatch)
5
+ * from untrusted fork/PR-adjacent events that must not receive privileged secrets.
6
+ */
7
+ /**
8
+ * GitHub event names treated as untrusted for privileged CI.
9
+ */
10
+ const UNTRUSTED_EVENTS = new Set([
11
+ "pull_request",
12
+ "pull_request_target",
13
+ "pull_request_review",
14
+ "pull_request_review_comment",
15
+ "issues",
16
+ "issue_comment",
17
+ "workflow_run",
18
+ ]);
19
+ /**
20
+ * Classify whether a GitHub Actions event should receive privileged secrets.
21
+ *
22
+ * Returns `untrusted` for known PR/issue/workflow_run events, pull refs, and
23
+ * any unrecognized event name. Only `push`, `release`, and `workflow_dispatch`
24
+ * are trusted.
25
+ *
26
+ * @param input - Event name and optional git ref from the workflow context.
27
+ * @returns `"trusted"` or `"untrusted"`.
28
+ */
29
+ export function classifyEventTrust(input) {
30
+ const eventName = input.eventName.trim().toLowerCase();
31
+ if (UNTRUSTED_EVENTS.has(eventName)) {
32
+ return "untrusted";
33
+ }
34
+ if (eventName === "push" || eventName === "release" || eventName === "workflow_dispatch") {
35
+ return "trusted";
36
+ }
37
+ if (input.ref?.startsWith("refs/pull/")) {
38
+ return "untrusted";
39
+ }
40
+ return "untrusted";
41
+ }
42
+ //# sourceMappingURL=classify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify.js","sourceRoot":"","sources":["../src/classify.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,cAAc;IACd,qBAAqB;IACrB,qBAAqB;IACrB,6BAA6B;IAC7B,QAAQ;IACR,eAAe;IACf,cAAc;CACf,CAAC,CAAA;AAEF;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAGlC;IACC,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IACtD,IAAI,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QACpC,OAAO,WAAW,CAAA;IACpB,CAAC;IACD,IAAI,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,mBAAmB,EAAE,CAAC;QACzF,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,OAAO,WAAW,CAAA;IACpB,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Remote CI privilege / deploy evaluation against a Limetry ActionPolicy.
3
+ */
4
+ import { type ActionEvaluationResponse, type ActionIntent } from "@limetry/sdk";
5
+ import { type EventTrust } from "./classify.js";
6
+ /**
7
+ * Successful ActionEvaluationResponse (`ok: true`) from `\@limetry/sdk`.
8
+ */
9
+ export type OkActionEvaluation = Extract<ActionEvaluationResponse, {
10
+ ok: true;
11
+ }>;
12
+ /**
13
+ * Inputs for {@link evaluateCiPrivilege}.
14
+ */
15
+ export type EvaluateCiPrivilegeInput = {
16
+ /**
17
+ * Limetry API base URL; passed through to {@link RemotePolicyEngine}.
18
+ */
19
+ baseUrl?: string;
20
+ /**
21
+ * Limetry API key / bearer token.
22
+ */
23
+ apiKey: string;
24
+ /**
25
+ * Tenant id for multi-tenant evaluation.
26
+ */
27
+ tenantId?: string;
28
+ /**
29
+ * ActionPolicy id to evaluate against.
30
+ */
31
+ policyId: string;
32
+ /**
33
+ * Agent id recorded on the ActionIntent.
34
+ */
35
+ agentId: string;
36
+ /**
37
+ * Whether this is a CI privilege check or a deploy gate.
38
+ */
39
+ actionType: "ci_privilege" | "deploy";
40
+ /**
41
+ * GitHub repository (`owner/repo`).
42
+ */
43
+ repository: string;
44
+ /**
45
+ * Commit SHA being gated.
46
+ */
47
+ sha: string;
48
+ /**
49
+ * GitHub Actions event name used for trust classification.
50
+ */
51
+ eventName: string;
52
+ /**
53
+ * Optional git ref; pull refs force untrusted classification.
54
+ */
55
+ ref?: string;
56
+ /**
57
+ * Optional fetch implementation for tests.
58
+ */
59
+ fetch?: typeof globalThis.fetch;
60
+ };
61
+ /**
62
+ * Combined trust classification, built intent, and successful evaluation result.
63
+ */
64
+ export type EvaluateCiPrivilegeResult = {
65
+ /**
66
+ * Local trust classification for the GitHub event.
67
+ */
68
+ trust: EventTrust;
69
+ /**
70
+ * ActionIntent submitted to Limetry.
71
+ */
72
+ intent: ActionIntent;
73
+ /**
74
+ * Successful remote evaluation response.
75
+ */
76
+ evaluation: OkActionEvaluation;
77
+ };
78
+ /**
79
+ * Classify event trust and evaluate a CI privilege or deploy ActionIntent.
80
+ *
81
+ * Builds a `repository@sha` resource, attaches `event_name` / `trust` / optional
82
+ * `ref` metadata, then calls {@link RemotePolicyEngine.evaluateAction}.
83
+ *
84
+ * @param input - API credentials, policy, repo context, and action type.
85
+ * @returns Trust label, intent, and successful evaluation.
86
+ * @throws Error When the remote evaluation returns `ok: false`.
87
+ */
88
+ export declare function evaluateCiPrivilege(input: EvaluateCiPrivilegeInput): Promise<EvaluateCiPrivilegeResult>;
89
+ //# sourceMappingURL=evaluate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EAElB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAGnE;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,wBAAwB,EAAE;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,CAAA;AAEhF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,UAAU,EAAE,cAAc,GAAG,QAAQ,CAAA;IACrC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,KAAK,EAAE,UAAU,CAAA;IACjB;;OAEG;IACH,MAAM,EAAE,YAAY,CAAA;IACpB;;OAEG;IACH,UAAU,EAAE,kBAAkB,CAAA;CAC/B,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,yBAAyB,CAAC,CA2BpC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Remote CI privilege / deploy evaluation against a Limetry ActionPolicy.
3
+ */
4
+ import { RemotePolicyEngine, } from "@limetry/sdk";
5
+ import { classifyEventTrust } from "./classify.js";
6
+ import { buildCiIntent, buildRepoShaResource } from "./intent.js";
7
+ /**
8
+ * Classify event trust and evaluate a CI privilege or deploy ActionIntent.
9
+ *
10
+ * Builds a `repository@sha` resource, attaches `event_name` / `trust` / optional
11
+ * `ref` metadata, then calls {@link RemotePolicyEngine.evaluateAction}.
12
+ *
13
+ * @param input - API credentials, policy, repo context, and action type.
14
+ * @returns Trust label, intent, and successful evaluation.
15
+ * @throws Error When the remote evaluation returns `ok: false`.
16
+ */
17
+ export async function evaluateCiPrivilege(input) {
18
+ const trust = classifyEventTrust({
19
+ eventName: input.eventName,
20
+ ref: input.ref,
21
+ });
22
+ const intent = buildCiIntent({
23
+ policyId: input.policyId,
24
+ agentId: input.agentId,
25
+ actionType: input.actionType,
26
+ resource: buildRepoShaResource(input.repository, input.sha),
27
+ metadata: {
28
+ event_name: input.eventName,
29
+ trust,
30
+ ...(input.ref ? { ref: input.ref } : {}),
31
+ },
32
+ });
33
+ const engine = new RemotePolicyEngine({
34
+ baseUrl: input.baseUrl,
35
+ apiKey: input.apiKey,
36
+ tenantId: input.tenantId,
37
+ fetch: input.fetch,
38
+ });
39
+ const evaluation = await engine.evaluateAction(intent);
40
+ if (!evaluation.ok) {
41
+ throw new Error(evaluation.error ?? "Limetry evaluate failed");
42
+ }
43
+ return { trust, intent, evaluation };
44
+ }
45
+ //# sourceMappingURL=evaluate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAGL,kBAAkB,GACnB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAmB,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AA2EjE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAA+B;IAE/B,MAAM,KAAK,GAAG,kBAAkB,CAAC;QAC/B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,aAAa,CAAC;QAC3B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,QAAQ,EAAE,oBAAoB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC;QAC3D,QAAQ,EAAE;YACR,UAAU,EAAE,KAAK,CAAC,SAAS;YAC3B,KAAK;YACL,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACzC;KACF,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC;QACpC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC,CAAA;IACF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;IACtD,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,IAAI,yBAAyB,CAAC,CAAA;IAChE,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,CAAA;AACtC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * CI privilege and deploy gating helpers for GitHub Actions (`\@limetry/ci`).
3
+ *
4
+ * Classifies event trust, builds ActionIntents, evaluates against a remote
5
+ * Limetry policy, verifies release receipts, and exposes the Action entrypoint.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { classifyEventTrust, type EventTrust } from "./classify.js";
10
+ export { evaluateCiPrivilege, type EvaluateCiPrivilegeInput, type EvaluateCiPrivilegeResult } from "./evaluate.js";
11
+ export { buildCiIntent, type BuildCiIntentInput, buildRepoShaResource } from "./intent.js";
12
+ export { type ReleaseReceiptFields, verifyReleaseReceipt } from "./receipt.js";
13
+ export { runAction } from "./run-action.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,eAAe,CAAA;AAClH,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAC,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,KAAK,oBAAoB,EAAC,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * CI privilege and deploy gating helpers for GitHub Actions (`\@limetry/ci`).
3
+ *
4
+ * Classifies event trust, builds ActionIntents, evaluates against a remote
5
+ * Limetry policy, verifies release receipts, and exposes the Action entrypoint.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { classifyEventTrust } from "./classify.js";
10
+ export { evaluateCiPrivilege } from "./evaluate.js";
11
+ export { buildCiIntent, buildRepoShaResource } from "./intent.js";
12
+ export { verifyReleaseReceipt } from "./receipt.js";
13
+ export { runAction } from "./run-action.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAmB,MAAM,eAAe,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAiE,MAAM,eAAe,CAAA;AAClH,OAAO,EAAE,aAAa,EAA0B,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACzF,OAAO,EAA4B,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * ActionIntent builders for CI privilege and deploy gating.
3
+ */
4
+ import type { ActionIntent } from "@limetry/sdk";
5
+ /**
6
+ * Inputs for {@link buildCiIntent}.
7
+ */
8
+ export type BuildCiIntentInput = {
9
+ /**
10
+ * Registered ActionPolicy id.
11
+ */
12
+ policyId: string;
13
+ /**
14
+ * Agent identity bound to the intent (for example `github_actions`).
15
+ */
16
+ agentId: string;
17
+ /**
18
+ * CI action type to evaluate.
19
+ */
20
+ actionType: "ci_privilege" | "deploy";
21
+ /**
22
+ * Resource string, typically `repository@sha` from {@link buildRepoShaResource}.
23
+ */
24
+ resource: string;
25
+ /**
26
+ * ISO-8601 issuance timestamp; defaults to now.
27
+ */
28
+ issuedAt?: string;
29
+ /**
30
+ * String metadata attached to the intent (event name, trust, ref, etc.).
31
+ */
32
+ metadata?: Record<string, string>;
33
+ };
34
+ /**
35
+ * Build an ActionIntent for CI privilege or release/deploy gating.
36
+ *
37
+ * @param input - Policy, agent, action type, resource, and optional metadata.
38
+ * @returns A new ActionIntent with a generated `intent_id`.
39
+ */
40
+ export declare function buildCiIntent(input: BuildCiIntentInput): ActionIntent;
41
+ /**
42
+ * Bind a repository and commit SHA into the ActionIntent resource field.
43
+ *
44
+ * @param repository - GitHub `owner/repo` string.
45
+ * @param sha - Commit SHA being gated.
46
+ * @returns Resource string in the form `repository@sha`.
47
+ */
48
+ export declare function buildRepoShaResource(repository: string, sha: string): string;
49
+ //# sourceMappingURL=intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../src/intent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEhD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,UAAU,EAAE,cAAc,GAAG,QAAQ,CAAA;IACrC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CAUrE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5E"}
package/dist/intent.js ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ActionIntent builders for CI privilege and deploy gating.
3
+ */
4
+ import { randomUUID } from "node:crypto";
5
+ /**
6
+ * Build an ActionIntent for CI privilege or release/deploy gating.
7
+ *
8
+ * @param input - Policy, agent, action type, resource, and optional metadata.
9
+ * @returns A new ActionIntent with a generated `intent_id`.
10
+ */
11
+ export function buildCiIntent(input) {
12
+ return {
13
+ intent_id: randomUUID(),
14
+ policy_id: input.policyId,
15
+ agent_id: input.agentId,
16
+ action_type: input.actionType,
17
+ resource: input.resource,
18
+ metadata: input.metadata,
19
+ issued_at: input.issuedAt ?? new Date().toISOString(),
20
+ };
21
+ }
22
+ /**
23
+ * Bind a repository and commit SHA into the ActionIntent resource field.
24
+ *
25
+ * @param repository - GitHub `owner/repo` string.
26
+ * @param sha - Commit SHA being gated.
27
+ * @returns Resource string in the form `repository@sha`.
28
+ */
29
+ export function buildRepoShaResource(repository, sha) {
30
+ return `${repository}@${sha}`;
31
+ }
32
+ //# sourceMappingURL=intent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent.js","sourceRoot":"","sources":["../src/intent.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAkCxC;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAyB;IACrD,OAAO;QACL,SAAS,EAAE,UAAU,EAAE;QACvB,SAAS,EAAE,KAAK,CAAC,QAAQ;QACzB,QAAQ,EAAE,KAAK,CAAC,OAAO;QACvB,WAAW,EAAE,KAAK,CAAC,UAAU;QAC7B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACtD,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAkB,EAAE,GAAW;IAClE,OAAO,GAAG,UAAU,IAAI,GAAG,EAAE,CAAA;AAC/B,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * HMAC decision receipt verification for release/deploy gating.
3
+ */
4
+ /**
5
+ * Fields of a Limetry decision receipt used for release verification.
6
+ */
7
+ export type ReleaseReceiptFields = {
8
+ /**
9
+ * Decision value (for example `allow` or `deny`).
10
+ */
11
+ decision: string;
12
+ /**
13
+ * Unique decision identifier.
14
+ */
15
+ decision_id: string;
16
+ /**
17
+ * Digest the receipt is bound to (typically a hash of the intent JSON).
18
+ */
19
+ digest: string;
20
+ /**
21
+ * Unix expiry timestamp in seconds.
22
+ */
23
+ exp: number;
24
+ /**
25
+ * Human-readable decision reasons.
26
+ */
27
+ reasons: string[];
28
+ /**
29
+ * Hex-encoded HMAC-SHA256 signature over the receipt payload.
30
+ */
31
+ sig: string;
32
+ };
33
+ /**
34
+ * Verify an HMAC decision receipt is bound to the expected digest (typically intent JSON hash).
35
+ * Matches server `createDecisionReceipt` payload formatting.
36
+ *
37
+ * Checks digest equality, expiry, then timing-safe HMAC comparison of:
38
+ * `decision_id.decision.digest.exp.reasonsJoinedByPipe`.
39
+ *
40
+ * @param input - Receipt fields, expected digest, and HMAC secret.
41
+ * @returns `true` when the receipt is unexpired, digest-matched, and signature-valid.
42
+ */
43
+ export declare function verifyReleaseReceipt(input: {
44
+ receipt: ReleaseReceiptFields;
45
+ expectedDigest: string;
46
+ secret: string;
47
+ }): boolean;
48
+ //# sourceMappingURL=receipt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipt.d.ts","sourceRoot":"","sources":["../src/receipt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,OAAO,EAAE,oBAAoB,CAAA;IAC7B,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAqBV"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * HMAC decision receipt verification for release/deploy gating.
3
+ */
4
+ import { createHmac, timingSafeEqual } from "node:crypto";
5
+ /**
6
+ * Verify an HMAC decision receipt is bound to the expected digest (typically intent JSON hash).
7
+ * Matches server `createDecisionReceipt` payload formatting.
8
+ *
9
+ * Checks digest equality, expiry, then timing-safe HMAC comparison of:
10
+ * `decision_id.decision.digest.exp.reasonsJoinedByPipe`.
11
+ *
12
+ * @param input - Receipt fields, expected digest, and HMAC secret.
13
+ * @returns `true` when the receipt is unexpired, digest-matched, and signature-valid.
14
+ */
15
+ export function verifyReleaseReceipt(input) {
16
+ if (input.receipt.digest !== input.expectedDigest) {
17
+ return false;
18
+ }
19
+ if (input.receipt.exp < Math.floor(Date.now() / 1000)) {
20
+ return false;
21
+ }
22
+ const payload = [
23
+ input.receipt.decision_id,
24
+ input.receipt.decision,
25
+ input.receipt.digest,
26
+ String(input.receipt.exp),
27
+ input.receipt.reasons.join("|"),
28
+ ].join(".");
29
+ const expected = createHmac("sha256", input.secret).update(payload).digest("hex");
30
+ const left = Buffer.from(expected, "utf8");
31
+ const right = Buffer.from(input.receipt.sig, "utf8");
32
+ if (left.length !== right.length) {
33
+ return false;
34
+ }
35
+ return timingSafeEqual(left, right);
36
+ }
37
+ //# sourceMappingURL=receipt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"receipt.js","sourceRoot":"","sources":["../src/receipt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAgCzD;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAIpC;IACC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,cAAc,EAAE,CAAC;QAClD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QACtD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,OAAO,GAAG;QACd,KAAK,CAAC,OAAO,CAAC,WAAW;QACzB,KAAK,CAAC,OAAO,CAAC,QAAQ;QACtB,KAAK,CAAC,OAAO,CAAC,MAAM;QACpB,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QACzB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;KAChC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACX,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACjF,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IACpD,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,OAAO,KAAK,CAAA;IACd,CAAC;IACD,OAAO,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACrC,CAAC"}
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * GitHub Action CLI entrypoint that evaluates CI privilege / deploy intents
4
+ * and writes decision outputs for downstream workflow steps.
5
+ */
6
+ /**
7
+ * GitHub Action entrypoint for Limetry CI privilege / deploy gating.
8
+ *
9
+ * Reads workflow inputs from `INPUT_*` / `LIMETRY_*` / `GITHUB_*` env vars,
10
+ * evaluates via {@link evaluateCiPrivilege}, and sets `decision`, `decision_id`,
11
+ * `approval_id`, and `receipt_digest` outputs.
12
+ *
13
+ * Exit codes:
14
+ * - `0` — allow (or approval_required when `fail_on_approval_required` is false)
15
+ * - `1` — missing inputs, untrusted event (when required), deny, or approval_required
16
+ *
17
+ * @param env - Process environment; defaults to `process.env`.
18
+ * @returns Process exit code (`0` success, `1` failure).
19
+ * @throws Propagates evaluation transport / remote errors to the caller.
20
+ */
21
+ export declare function runAction(env?: NodeJS.ProcessEnv): Promise<number>;
22
+ //# sourceMappingURL=run-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-action.d.ts","sourceRoot":"","sources":["../src/run-action.ts"],"names":[],"mappings":";AACA;;;GAGG;AAoCH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiErF"}
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * GitHub Action CLI entrypoint that evaluates CI privilege / deploy intents
4
+ * and writes decision outputs for downstream workflow steps.
5
+ */
6
+ import { appendFileSync } from "node:fs";
7
+ import { evaluateCiPrivilege } from "./evaluate.js";
8
+ /**
9
+ * Parse a boolean env/input string with a fallback when unset or empty.
10
+ *
11
+ * @param value - Raw env value (`"true"` / `"1"` are truthy).
12
+ * @param fallback - Value used when `value` is undefined or empty.
13
+ * @returns Parsed boolean.
14
+ */
15
+ function readBoolean(value, fallback) {
16
+ if (value === undefined || value === "") {
17
+ return fallback;
18
+ }
19
+ return value === "true" || value === "1";
20
+ }
21
+ /**
22
+ * Write a GitHub Actions output, or print `name=value` to stdout when
23
+ * `GITHUB_OUTPUT` is unset.
24
+ *
25
+ * @param name - Output name.
26
+ * @param value - Output value.
27
+ */
28
+ function setOutput(name, value) {
29
+ const destination = process.env.GITHUB_OUTPUT;
30
+ if (!destination) {
31
+ process.stdout.write(`${name}=${value}\n`);
32
+ return;
33
+ }
34
+ appendFileSync(destination, `${name}=${value}\n`);
35
+ }
36
+ /**
37
+ * GitHub Action entrypoint for Limetry CI privilege / deploy gating.
38
+ *
39
+ * Reads workflow inputs from `INPUT_*` / `LIMETRY_*` / `GITHUB_*` env vars,
40
+ * evaluates via {@link evaluateCiPrivilege}, and sets `decision`, `decision_id`,
41
+ * `approval_id`, and `receipt_digest` outputs.
42
+ *
43
+ * Exit codes:
44
+ * - `0` — allow (or approval_required when `fail_on_approval_required` is false)
45
+ * - `1` — missing inputs, untrusted event (when required), deny, or approval_required
46
+ *
47
+ * @param env - Process environment; defaults to `process.env`.
48
+ * @returns Process exit code (`0` success, `1` failure).
49
+ * @throws Propagates evaluation transport / remote errors to the caller.
50
+ */
51
+ export async function runAction(env = process.env) {
52
+ const eventName = env.GITHUB_EVENT_NAME ?? env.INPUT_EVENT_NAME ?? "";
53
+ const sha = env.GITHUB_SHA ?? "";
54
+ const repository = env.GITHUB_REPOSITORY ?? "";
55
+ const ref = env.GITHUB_REF;
56
+ const apiKey = env.INPUT_LIMETRY_API_KEY ?? env.LIMETRY_API_KEY ?? "";
57
+ const baseUrl = env.INPUT_LIMETRY_BASE_URL ?? env.LIMETRY_BASE_URL;
58
+ const policyId = env.INPUT_POLICY_ID ?? env.LIMETRY_POLICY_ID ?? "";
59
+ const agentId = env.INPUT_AGENT_ID ?? "github_actions";
60
+ const actionTypeRaw = env.INPUT_ACTION_TYPE ?? "ci_privilege";
61
+ const actionType = actionTypeRaw === "deploy" ? "deploy" : "ci_privilege";
62
+ const requireTrusted = readBoolean(env.INPUT_REQUIRE_TRUSTED, true);
63
+ const failOnApprovalRequired = readBoolean(env.INPUT_FAIL_ON_APPROVAL_REQUIRED, true);
64
+ if (!apiKey || !policyId || !repository || !sha || !eventName) {
65
+ process.stderr.write("Missing required CI inputs (api key, policy id, repository, sha, or event name)\n");
66
+ return 1;
67
+ }
68
+ const result = await evaluateCiPrivilege({
69
+ baseUrl,
70
+ apiKey,
71
+ policyId,
72
+ agentId,
73
+ actionType,
74
+ repository,
75
+ sha,
76
+ eventName,
77
+ ref,
78
+ });
79
+ setOutput("decision", result.evaluation.decision ?? "deny");
80
+ setOutput("decision_id", result.evaluation.decision_id ?? "");
81
+ setOutput("approval_id", result.evaluation.approval_id ?? "");
82
+ const receipt = result.evaluation.receipt;
83
+ setOutput("receipt_digest", receipt?.digest ?? "");
84
+ if (requireTrusted && result.trust === "untrusted") {
85
+ process.stderr.write(`Refusing privileged CI for untrusted event ${eventName} on ${result.intent.resource}\n`);
86
+ return 1;
87
+ }
88
+ if (result.evaluation.decision === "deny") {
89
+ process.stderr.write(`Limetry denied ${actionType}: ${(result.evaluation.reasons ?? []).join("; ")}\n`);
90
+ return 1;
91
+ }
92
+ if (result.evaluation.decision === "approval_required" && failOnApprovalRequired) {
93
+ process.stderr.write(`Limetry requires approval (${result.evaluation.approval_id ?? "unknown"}): ` +
94
+ `${(result.evaluation.reasons ?? []).join("; ")}\n`);
95
+ return 1;
96
+ }
97
+ process.stdout.write(`Limetry ${result.evaluation.decision ?? "allow"} for ${result.intent.resource}\n`);
98
+ return 0;
99
+ }
100
+ /**
101
+ * True when this module is executed directly rather than imported.
102
+ */
103
+ const isDirectRun = process.argv[1]?.endsWith("run-action.js") ||
104
+ process.argv[1]?.endsWith("run-action.ts");
105
+ if (isDirectRun) {
106
+ void runAction()
107
+ .then((code) => {
108
+ process.exit(code);
109
+ })
110
+ .catch((error) => {
111
+ const message = error instanceof Error ? error.message : String(error);
112
+ process.stderr.write(`${message}\n`);
113
+ process.exit(1);
114
+ });
115
+ }
116
+ //# sourceMappingURL=run-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-action.js","sourceRoot":"","sources":["../src/run-action.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,42 @@
1
+ name: Governed release gate
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ privilege:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v5
13
+ - name: Evaluate CI privilege
14
+ uses: limetry/limetry/packages/ci@main
15
+ with:
16
+ limetry_api_key: ${{ secrets.LIMETRY_API_KEY }}
17
+ limetry_base_url: ${{ vars.LIMETRY_BASE_URL }}
18
+ policy_id: ${{ vars.LIMETRY_CI_POLICY_ID }}
19
+ action_type: ci_privilege
20
+ require_trusted: "false"
21
+
22
+ deploy:
23
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
24
+ needs: privilege
25
+ runs-on: ubuntu-latest
26
+ permissions:
27
+ id-token: write
28
+ contents: read
29
+ steps:
30
+ - uses: actions/checkout@v5
31
+ - name: Evaluate deploy
32
+ id: limetry
33
+ uses: limetry/limetry/packages/ci@main
34
+ with:
35
+ limetry_api_key: ${{ secrets.LIMETRY_API_KEY }}
36
+ limetry_base_url: ${{ vars.LIMETRY_BASE_URL }}
37
+ policy_id: ${{ vars.LIMETRY_DEPLOY_POLICY_ID }}
38
+ action_type: deploy
39
+ require_trusted: "true"
40
+ - name: Use production secrets only after allow
41
+ if: steps.limetry.outputs.decision == 'allow'
42
+ run: echo "Deploying ${{ github.sha }}"
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@limetry/ci",
3
+ "version": "1.2.49",
4
+ "description": "Limetry GitHub Action and helpers for CI privilege and release gating",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "bin": {
16
+ "limetry-ci": "dist/run-action.js"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "action.yml",
21
+ "examples",
22
+ "policies"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/limetry/limetry.git",
31
+ "directory": "packages/ci"
32
+ },
33
+ "scripts": {
34
+ "prepack": "node ../../scripts/rewrite-workspace-protocol.mjs prepare",
35
+ "postpack": "node ../../scripts/rewrite-workspace-protocol.mjs restore",
36
+ "build": "tsc -p tsconfig.json",
37
+ "test": "vitest run --coverage",
38
+ "typecheck": "tsgo -p tsconfig.json --noEmit"
39
+ },
40
+ "peerDependencies": {
41
+ "@limetry/sdk": "*"
42
+ },
43
+ "devDependencies": {
44
+ "@limetry/sdk": "^1.2.49",
45
+ "@types/node": "^26.4.1",
46
+ "@vitest/coverage-v8": "4.1.11",
47
+ "typescript": "^5.8.2",
48
+ "vitest": "4.1.11"
49
+ },
50
+ "engines": {
51
+ "node": ">=20"
52
+ }
53
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "policy_id": "11111111-1111-4111-8111-111111111111",
3
+ "version": 1,
4
+ "organization_id": "default",
5
+ "agent_id": "github_actions",
6
+ "allowed_action_types": ["ci_privilege"],
7
+ "denied_action_types": ["deploy"],
8
+ "audit_mode": "minimal",
9
+ "status": "active",
10
+ "updated_at": "2026-08-18T00:00:00.000Z",
11
+ "effective_from": "2026-01-01T00:00:00.000Z",
12
+ "expires_at": null
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "policy_id": "22222222-2222-4222-8222-222222222222",
3
+ "version": 1,
4
+ "organization_id": "default",
5
+ "agent_id": "github_actions",
6
+ "allowed_action_types": ["ci_privilege", "deploy"],
7
+ "denied_action_types": [],
8
+ "audit_mode": "minimal",
9
+ "status": "active",
10
+ "updated_at": "2026-08-18T00:00:00.000Z",
11
+ "effective_from": "2026-01-01T00:00:00.000Z",
12
+ "expires_at": null
13
+ }