Skip to content

feat: add repeatable --env flag to push (#734) - #1352

Draft
MatousMarik wants to merge 2 commits into
feat/actor-json-apply-env-vars-to-build-734from
feat/push-env-flag-734
Draft

feat: add repeatable --env flag to push (#734)#1352
MatousMarik wants to merge 2 commits into
feat/actor-json-apply-env-vars-to-build-734from
feat/push-env-flag-734

Conversation

@MatousMarik

@MatousMarik MatousMarik commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Completes #734, stacked on #1346 (retarget to master as the stack merges — only the last two commits are new here).

What

  • Repeatable --env KEY=VALUE flag on apify push, primarily for passing build args / env vars in CI without touching actor.json or the Console.
  • Values are merged with environmentVariables from .actor/actor.json; on key conflict the --env value wins. @secret references resolve the same way as in the file (via apify secrets add). Malformed values (no KEY=) fail fast with exit code 5 before anything is uploaded.
  • Framework (own commit): Flags.string({ multiple: true }) — multi-value string flags typed as string[]. The parser already registered every flag with multiple: true and collapsed the array in _parseFlags; flags tagged multi-value now keep it. Includes the 'strings' flag tag in type inference and both help renderers. choices and default are type-forbidden together with multiple: true (unimplemented in parsing); The short-form -x=value leading-= strip is applied per element for multi-value flags (unit-tested); stdin with multiple remains a known ceiling.

Resulting env var semantics

environmentVariables in actor.json --env Env vars on the platform after push
absent none Preserved (field omitted from the API call — unchanged behavior)
absent --env A=1 Replaced with the CLI vars — Console-set vars are removed (documented with a caution in vars.md and the flag description)
{...} none Replaced by the file's vars (unchanged behavior)
{} (empty object) none Cleared (unchanged behavior — an explicit empty value)
{...} --env ... Replaced by the merge; CLI wins per key

Tests

  • Unit tests for the KEY=VALUE parser (merge order, = in values, empty value, malformed entries).
  • Unit tests for multi-value flag parsing (repeated values collect, scalars wrap, absent stays undefined, single-value flags still reject repeats).
  • New [api] tests: file + CLI vars merge with CLI winning; @secret refs from both actor.json and --env land as isSecret: true and never come back in plain text; platform vars preserved when the field is absent and cleared by an explicit {} (pins the table above). Full push API suite passes (17/17), plus test:local, lint, format, build.
  • Manually verified the real argv path: repeated --env parses, malformed value exits 5.

No new dependencies; no install-size impact.

@MatousMarik
MatousMarik force-pushed the feat/push-env-flag-734 branch 3 times, most recently from 95273c9 to 348713b Compare August 25, 2026 15:50
Flags.string({ multiple: true }) collects repeated flag values into a
string[] instead of rejecting the second occurrence. The parser already
registered every flag with multiple: true; the value was collapsed and
guarded in _parseFlags, which now keeps the array for flags tagged as
multi-value.
Passes environment variables in KEY=VALUE format directly to the
Actor version, primarily for CI. The values are merged with
environmentVariables from actor.json, with the CLI value winning on
key conflicts. @secret references resolve the same way as in the
file.
@MatousMarik
MatousMarik force-pushed the feat/push-env-flag-734 branch from 348713b to 414f9dc Compare August 25, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants