diff --git a/src/commands/deploy/deploy.ts b/src/commands/deploy/deploy.ts index 1a0cff793f2..6d845206f79 100644 --- a/src/commands/deploy/deploy.ts +++ b/src/commands/deploy/deploy.ts @@ -581,7 +581,12 @@ const runDeploy = async ({ } const draft = options.draft || (!deployToProduction && !alias) - const createDeployBody = { draft, branch: alias, include_upload_url: options.uploadSourceZip } + const createDeployBody = { + draft, + branch: alias, + include_upload_url: options.uploadSourceZip, + deploy_source: 'cli', + } const createDeployResponse = await api.createSiteDeploy({ siteId, title, body: createDeployBody }) deployId = createDeployResponse.id as string @@ -1358,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 } + const createDeployBody = { draft, branch: alias, include_upload_url: options.uploadSourceZip, 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 1490cf5215c..dab1038b5eb 100644 --- a/tests/integration/commands/deploy/deploy.test.ts +++ b/tests/integration/commands/deploy/deploy.test.ts @@ -1483,6 +1483,30 @@ describe.concurrent('deploy command', () => { }) }) + test('should include deploy_source cli 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 }), + ).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('cli') + }) + }) + }) + test('should include build_version in deploy body', async (t) => { await withMockDeploy(async (mockApi, deployState) => { await withSiteBuilder(t, async (builder) => {