Skip to content

feat: add --apply-env-vars-to-build flag to push (#734) - #1345

Open
MatousMarik wants to merge 3 commits into
masterfrom
feat/push-apply-env-vars-to-build-734
Open

feat: add --apply-env-vars-to-build flag to push (#734)#1345
MatousMarik wants to merge 3 commits into
masterfrom
feat/push-apply-env-vars-to-build-734

Conversation

@MatousMarik

@MatousMarik MatousMarik commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Part of #734 (the applyEnvVarsToBuild toggle half).

What

  • New --apply-env-vars-to-build boolean flag on apify push — sets applyEnvVarsToBuild: true on the Actor version, so env vars from actor.json are also available during the Docker build. --no-apply-env-vars-to-build explicitly turns the setting off.
  • When the flag is omitted, the field is left out of the API payload entirely, so a value previously set in Console is preserved (pushes to existing Actors don't reset it).
  • Flag-parser tweak: _parseFlags matched provided flags by truthiness. The real CLI path is unaffected (multiple: true means values always arrive as arrays, which are truthy), but testRunCommand/internalRunCommand inject scalar values, where an explicit false was silently dropped. The matcher now checks for presence, and the required-flag check is aligned to undefined, so harness-injected negated booleans behave the same as parsed ones (the new test relies on this).
  • Regenerated docs/ via pnpm run update-docs.

Why

Env vars synced by apify push currently apply only at runtime; making them apply to the build requires flipping a switch in Console. That breaks CI and fresh pushes of Actors that need build-time secrets (e.g. a GitHub token as a Docker build arg).

Tests

  • New [api] test in test/api/commands/push.test.ts covering: flag → true, omitted → preserved, negated flag → false. Full push API suite passes (13/13), plus test:local, lint, format, build.

Follow-ups (separate PRs)

No new dependencies; no install-size impact.

@MatousMarik
MatousMarik force-pushed the feat/push-apply-env-vars-to-build-734 branch from f9e8ca3 to 9c96569 Compare August 24, 2026 14:39
@MatousMarik
MatousMarik marked this pull request as ready for review August 24, 2026 14:55
@MatousMarik MatousMarik self-assigned this Aug 24, 2026
@MatousMarik
MatousMarik force-pushed the feat/push-apply-env-vars-to-build-734 branch from 9c96569 to 923d4a8 Compare August 25, 2026 07:42
Allows env vars from actor.json to be applied to the Actor build
process (Docker build args) without flipping the switch in Console.
--no-apply-env-vars-to-build explicitly turns the setting off. When
the flag is omitted, the value stored on the platform is kept.

The flag parser matched provided flags by truthiness, which dropped
scalar false values injected by the test harness (the real CLI path
always yields arrays via multiple: true and was unaffected); it now
checks for presence so harness-injected negated booleans behave the
same as parsed ones.

@apify-factory apify-factory left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nothing blocking.

let rawFlag = rawFlags[matchingFlags[0]];

if (!rawFlag && builderData.required) {
if (typeof rawFlag === 'undefined' && builderData.required) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there will be conflict in this line, upstream version with Object.hasOwn seem better idea to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed — #1332 landed the same presence check with Object.hasOwn, so the merge commit drops my line and keeps yours. Only the required-flag check (!rawFlagtypeof rawFlag === "undefined") remains from this PR, which is still needed so --no-<flag> (false) does not read as missing.

@l2ysho l2ysho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx @MatousMarik
LGTM! 🚀

MatousMarik and others added 2 commits September 2, 2026 13:56
Upstream #1332 landed the same provided-flag presence check using
Object.hasOwn; keep the upstream line and drop the duplicate. Adopt
upstream push.ts around the rental sunset notice, keeping
applyEnvVarsToBuild in the version payload.
@l2ysho
l2ysho enabled auto-merge (squash) September 3, 2026 07: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.

4 participants