import { evaluateCondition } from "../expressions";
import type { ExprContext } from "../expressions";
import { interpolate, plainText } from "../segments";
import type { Segment } from "../segments";
import type { StepSpec } from "../spec";
import type { ResolvedAction, ResolvedActions } from "./resolve";
import type { ResolvedImage } from "./images";
/**
* The secret `${{ github.token }}` (and `${{ secrets.GITHUB_TOKEN }}`) stands for in an action's `with:` inputs. Actions use it against
* api.github.com (release lookups, tool downloads), where a gitfor token is useless and anonymous calls from
* shared egress IPs are rate limited at once; a repository or org secret with this name supplies a real one.
*/
export const GITHUB_COM_TOKEN_SECRET = "GITHUB_COM_TOKEN";
const GITHUB_TOKEN_EXPRESSION = /\$\{\{\s*(?:github\.token|secrets\.GITHUB_TOKEN)\s*\}\}/g;
const DEFAULT_PHASE_CONDITION = "always()";
/** Input names become `INPUT_<NAME>=` arguments to env(1), so `=` or control characters must not appear. */
const INPUT_NAME = /^[A-Za-z0-9_][A-Za-z0-9_ .-]{0,99}$/;
/** How a Docker action step runs on the runner (see `__gitfor_docker_run`). */
export type CompiledDocker = {
image: ({ kind: "registry" } & ResolvedImage) | { kind: "dockerfile"; path: string };
/** Overrides the image's ENTRYPOINT for the main phase; null keeps it. */
entrypoint: string | null;
args: Segment[][];
env: Array<[string, Segment[]]>;
};
export type CompiledAction = {
uses: string;
/** `owner/repo@ref` (or `./path`) for logs. */
label: string;
local: boolean;
repository: string | null;
ref: string | null;
sha: string | null;
path: string;
archive: { key: string; sha256: string } | null;
main: string;
pre: string | null;