-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathdeploy-experimental.js
executable file
·40 lines (29 loc) · 1.31 KB
/
deploy-experimental.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {execaSync} from 'execa'
async function deploy() {
const changes = execaSync("git", ["status", "--porcelain"]).stdout.trim()
// validate that we have a clean state
if (changes.length > 0) {
console.log("❌ You have uncommitted changes. Please commit or stash them before deploying.")
process.exit(1)
}
// get current branch
const currentBranch = execaSync("git", ["branch","--show-current"]).stdout.trim()
console.log(`🏗️ Preparing to deploy "${currentBranch}" to experimental`)
// change to experimental
execaSync("git", ["checkout", "experimental"])
// reset experimental
console.log("🔄 Updating experimental branch...")
execaSync("git", ["reset", "--hard", currentBranch])
// push force experimental
console.log("🙌 Pushing experimental branch...")
execaSync("git", ["push", "origin", "experimental", "-f"])
execaSync("git", ["checkout", currentBranch])
// Wait a bit while shipit receives all the info
await (new Promise(resolve => setTimeout(resolve, 2000)));
// navigate to shipit
const commit = execaSync("git", ["rev-parse", "HEAD"]).stdout.trim()
const url = `https://shipit.shopify.io/shopify/cli/experimental/deploys/new/${commit}`
console.log(`✅ Done! go to shipit and hit deploy! ->\n ${url}`)
execaSync("open", [url])
}
await deploy()