From f9fb9125bfc28ac3d13c2ffad04a8c8700265004 Mon Sep 17 00:00:00 2001 From: Amun Sihra Date: Tue, 21 Apr 2026 16:13:30 -0400 Subject: [PATCH 1/2] feat: support NETLIFY_DEPLOY_SOURCE env var --- src/commands/deploy/deploy.ts | 4 +-- .../commands/deploy/deploy.test.ts | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/commands/deploy/deploy.ts b/src/commands/deploy/deploy.ts index 6d845206f79..577a7858a76 100644 --- a/src/commands/deploy/deploy.ts +++ b/src/commands/deploy/deploy.ts @@ -585,7 +585,7 @@ const runDeploy = async ({ draft, branch: alias, include_upload_url: options.uploadSourceZip, - deploy_source: 'cli', + deploy_source: process.env.NETLIFY_DEPLOY_SOURCE || 'cli', } const createDeployResponse = await api.createSiteDeploy({ siteId, title, body: createDeployBody }) @@ -1363,7 +1363,7 @@ export const deploy = async (options: DeployOptionValues, command: BaseCommand) } const draft = options.draft || (!deployToProduction && !alias) - const createDeployBody = { draft, branch: alias, include_upload_url: options.uploadSourceZip, deploy_source: 'cli' } + const createDeployBody = { draft, branch: alias, include_upload_url: options.uploadSourceZip, deploy_source: process.env.NETLIFY_DEPLOY_SOURCE || 'cli' } // TODO: Type this properly in `@netlify/api`. const deployMetadata = (await api.createSiteDeploy({ diff --git a/tests/integration/commands/deploy/deploy.test.ts b/tests/integration/commands/deploy/deploy.test.ts index dab1038b5eb..d14d7139f43 100644 --- a/tests/integration/commands/deploy/deploy.test.ts +++ b/tests/integration/commands/deploy/deploy.test.ts @@ -1507,6 +1507,34 @@ describe.concurrent('deploy command', () => { }) }) + test('should honor NETLIFY_DEPLOY_SOURCE env var in create deploy request', async (t) => { + await withMockDeploy(async (mockApi) => { + await withSiteBuilder(t, async (builder) => { + builder.withContentFile({ + path: 'public/index.html', + content: '

test

', + }) + + await builder.build() + + await callCli( + ['deploy', '--json', '--no-build', '--dir', 'public'], + getCLIOptions({ + apiUrl: mockApi.apiUrl, + builder, + env: { NETLIFY_DEPLOY_SOURCE: 'agent_runner' }, + }), + ).then(parseDeploy) + + const createDeployRequest = mockApi.requests.find( + (req) => req.method === 'POST' && req.path === '/api/v1/sites/site_id/deploys', + ) + expect(createDeployRequest).toBeDefined() + expect((createDeployRequest!.body as Record).deploy_source).toBe('agent_runner') + }) + }) + }) + test('should include build_version in deploy body', async (t) => { await withMockDeploy(async (mockApi, deployState) => { await withSiteBuilder(t, async (builder) => { From 3a984ab819e29d2ae67fa90257302e2920f64cdb Mon Sep 17 00:00:00 2001 From: Amun Sihra Date: Tue, 21 Apr 2026 16:25:09 -0400 Subject: [PATCH 2/2] prettier fix --- src/commands/deploy/deploy.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/commands/deploy/deploy.ts b/src/commands/deploy/deploy.ts index 577a7858a76..742f7f198fe 100644 --- a/src/commands/deploy/deploy.ts +++ b/src/commands/deploy/deploy.ts @@ -1363,7 +1363,12 @@ export const deploy = async (options: DeployOptionValues, command: BaseCommand) } const draft = options.draft || (!deployToProduction && !alias) - const createDeployBody = { draft, branch: alias, include_upload_url: options.uploadSourceZip, deploy_source: process.env.NETLIFY_DEPLOY_SOURCE || 'cli' } + const createDeployBody = { + draft, + branch: alias, + include_upload_url: options.uploadSourceZip, + deploy_source: process.env.NETLIFY_DEPLOY_SOURCE || 'cli', + } // TODO: Type this properly in `@netlify/api`. const deployMetadata = (await api.createSiteDeploy({