Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const getRunBuildOptions = async ({
defaultConfig,
deployHandler,
deployId,
options: { context, cwd, debug, dry, json, offline, silent },
options: { alias, context, cwd, debug, dry, json, offline, silent },
packagePath,
skewProtectionToken,
token,
Expand Down Expand Up @@ -186,6 +186,7 @@ export const getRunBuildOptions = async ({
token: token ?? undefined,
dry,
debug,
branch: alias,
context,
mode: 'cli',
telemetry: false,
Expand Down
42 changes: 42 additions & 0 deletions tests/integration/commands/deploy/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,48 @@ describe.concurrent('deploy command', () => {
})
})

test('should use alias as the branch for both the deploy request and the build', async (t) => {
await withMockDeploy(async (mockApi) => {
await withSiteBuilder(t, async (builder) => {
builder
.withContentFile({
path: 'public/index.html',
content: '<h1>test</h1>',
})
.withNetlifyToml({
config: {
build: { publish: 'public' },
plugins: [{ package: './plugins/log-branch' }],
},
})
.withBuildPlugin({
name: 'log-branch',
plugin: {
async onPreBuild() {
console.log(`TEST_BRANCH: ${require('process').env.BRANCH}`)
},
},
})

await builder.build()

const output: string = await callCli(
['deploy', '--alias', 'custom-alias', '--context', 'deploy-preview'],
getCLIOptions({ apiUrl: mockApi.apiUrl, builder }),
)

const [, branch] = output.match(/TEST_BRANCH: (.+)/) ?? []
expect(branch).toBe('custom-alias')

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<string, unknown>).branch).toBe('custom-alias')
})
})
})

test('should include build_version in deploy body', async (t) => {
await withMockDeploy(async (mockApi, deployState) => {
await withSiteBuilder(t, async (builder) => {
Expand Down
Loading