Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 102bc6f

Browse files
authored
Merge pull request #155 from netlify/feat/update_existing_deploy
feat(deploy): allow updating an existing deploy
2 parents e9bef2e + d64145d commit 102bc6f

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ Optional `opts` include:
190190
} */
191191
// See https://github.com/netlify/cli/blob/v2.0.0-beta.3/src/commands/deploy.js#L161-L195
192192
// for an example of how this can be used.
193-
}
193+
},
194+
// passing a deployId will update an existing deploy based on the provided options
195+
deployId: null
194196
}
195197
```
196198

src/deploy/index.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ module.exports = async (api, siteId, dir, opts) => {
3232
phase: [start, progress, stop],
3333
spinner: a spinner from cli-spinners package
3434
} */
35-
}
35+
},
36+
// allows updating an existing deploy
37+
deployId: null
3638
},
3739
opts
3840
)
@@ -64,9 +66,9 @@ module.exports = async (api, siteId, dir, opts) => {
6466
phase: 'start'
6567
})
6668

67-
const deployParams = cleanDeep({
69+
let deploy
70+
let deployParams = cleanDeep({
6871
siteId,
69-
title,
7072
body: {
7173
files,
7274
functions,
@@ -75,8 +77,16 @@ module.exports = async (api, siteId, dir, opts) => {
7577
draft: opts.draft
7678
}
7779
})
80+
if (opts.deployId === null) {
81+
if(title) {
82+
deployParams = { ...deployParams, title }
83+
}
84+
deploy = await api.createSiteDeploy(deployParams)
85+
} else {
86+
deployParams = { ...deployParams, deploy_id: opts.deployId }
87+
deploy = await api.updateSiteDeploy(deployParams)
88+
}
7889

79-
let deploy = await api.createSiteDeploy(deployParams)
8090
if (deployParams.body.async) deploy = await waitForDiff(api, deploy.id, siteId, opts.deployTimeout)
8191

8292
const { id: deployId, required: requiredFiles, required_functions: requiredFns } = deploy

0 commit comments

Comments
 (0)