Skip to content

Commit 289933d

Browse files
authored
feat: Add deploy_source to CLI deploy requests (EX-2032) (#8155)
πŸŽ‰ Thanks for submitting a pull request! πŸŽ‰ #### Summary Explicitly sends deploy_source: 'cli' in the create deploy request body so that bitballoon can distinguish CLI deploys from other API consumers. This enables the UI to show "Last deployed from CLI" instead of grouping CLI deploys under "Drop". Fixes: https://linear.app/netlify/issue/EX-2032/last-deployed-from-ardrop-label-followup <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve and how? --> --- For us to review and ship your PR efficiently, please perform the following steps: - [ ] Open a [bug/issue](https://github.com/netlify/cli/issues/new/choose) before writing your code πŸ§‘β€πŸ’». This ensures we can discuss the changes and get feedback from everyone that should be involved. If you\`re fixing a typo or something that\`s on fire πŸ”₯ (e.g. incident related), you can skip this step. - [ ] Read the [contribution guidelines](../CONTRIBUTING.md) πŸ“–. This ensures your code follows our style guide and passes our tests. - [ ] Update or add tests (if any source code was changed or added) πŸ§ͺ - [ ] Update or add documentation (if features were changed or added) πŸ“ - [ ] Make sure the status checks below are successful βœ… **A picture of a cute animal (not mandatory, but encouraged)** <img width="332" height="263" alt="image" src="https://github.com/user-attachments/assets/6603af6c-f753-4eff-8299-3467a0535a4c" />
1 parent ca9d3ca commit 289933d

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

β€Žsrc/commands/deploy/deploy.tsβ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,12 @@ const runDeploy = async ({
581581
}
582582

583583
const draft = options.draft || (!deployToProduction && !alias)
584-
const createDeployBody = { draft, branch: alias, include_upload_url: options.uploadSourceZip }
584+
const createDeployBody = {
585+
draft,
586+
branch: alias,
587+
include_upload_url: options.uploadSourceZip,
588+
deploy_source: 'cli',
589+
}
585590

586591
const createDeployResponse = await api.createSiteDeploy({ siteId, title, body: createDeployBody })
587592
deployId = createDeployResponse.id as string
@@ -1358,7 +1363,7 @@ export const deploy = async (options: DeployOptionValues, command: BaseCommand)
13581363
}
13591364

13601365
const draft = options.draft || (!deployToProduction && !alias)
1361-
const createDeployBody = { draft, branch: alias, include_upload_url: options.uploadSourceZip }
1366+
const createDeployBody = { draft, branch: alias, include_upload_url: options.uploadSourceZip, deploy_source: 'cli' }
13621367

13631368
// TODO: Type this properly in `@netlify/api`.
13641369
const deployMetadata = (await api.createSiteDeploy({

β€Žtests/integration/commands/deploy/deploy.test.tsβ€Ž

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,30 @@ describe.concurrent('deploy command', () => {
14831483
})
14841484
})
14851485

1486+
test('should include deploy_source cli in create deploy request', async (t) => {
1487+
await withMockDeploy(async (mockApi) => {
1488+
await withSiteBuilder(t, async (builder) => {
1489+
builder.withContentFile({
1490+
path: 'public/index.html',
1491+
content: '<h1>test</h1>',
1492+
})
1493+
1494+
await builder.build()
1495+
1496+
await callCli(
1497+
['deploy', '--json', '--no-build', '--dir', 'public'],
1498+
getCLIOptions({ apiUrl: mockApi.apiUrl, builder }),
1499+
).then(parseDeploy)
1500+
1501+
const createDeployRequest = mockApi.requests.find(
1502+
(req) => req.method === 'POST' && req.path === '/api/v1/sites/site_id/deploys',
1503+
)
1504+
expect(createDeployRequest).toBeDefined()
1505+
expect((createDeployRequest!.body as Record<string, unknown>).deploy_source).toBe('cli')
1506+
})
1507+
})
1508+
})
1509+
14861510
test('should include build_version in deploy body', async (t) => {
14871511
await withMockDeploy(async (mockApi, deployState) => {
14881512
await withSiteBuilder(t, async (builder) => {

0 commit comments

Comments
Β (0)