forked from zendesk/linksf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
42 lines (36 loc) · 1.27 KB
/
Copy pathdeploy.js
File metadata and controls
42 lines (36 loc) · 1.27 KB
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
41
42
/**
* React Static Boilerplate
* https://github.com/koistya/react-static-boilerplate
* Copyright (c) Konstantin Tarkus (@koistya) | MIT license
*/
import GitRepo from 'git-repository'
import task from './lib/task'
// TODO: Update deployment URL
const remote = {
name: 'github',
url: 'https://github.com/{user}/{repo}.git',
branch: 'gh-pages',
}
/**
* Deploy the contents of the `/build` folder to GitHub Pages.
*/
export default task(async function deploy() {
// Initialize a new Git repository inside the `/build` folder
// if it doesn't exist yet
const repo = await GitRepo.open('build', { init: true })
await repo.setRemote(remote.name, remote.url)
// Fetch the remote repository if it exists
if ((await repo.hasRef(remote.url, remote.branch))) {
await repo.fetch(remote.name)
await repo.reset(`${remote.name}/${remote.branch}`, { hard: true })
await repo.clean({ force: true })
}
// Build the project in RELEASE mode which
// generates optimized and minimized bundles
process.argv.push('release')
await require('./build')()
// Push the contents of the build folder to the remote server via Git
await repo.add('--all .')
await repo.commit('Update ' + new Date().toISOString())
await repo.push(remote.name, 'master:' + remote.branch)
})