forked from microsoft/vscode-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (54 loc) · 1.73 KB
/
gulpfile.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const gulp = require('gulp')
const $ = require('shelljs')
const GITHUB_TOKEN = process.env['GITHUB_TOKEN']
const BRANCH = process.env['BUILD_SOURCEBRANCHNAME']
if (!GITHUB_TOKEN) {
$.echo('This script clones vscode-website and requires access token')
$.exit(1)
}
const URL = `https://${GITHUB_TOKEN}@github.com/microsoft/vscode-website`
/**
* This task
* - Clones vscode-website
* - Clones vscode-website-dist
* - Uses vscode-docs:[current-branch] + vscode-website:release/prod to build to vscode-website-dist:[current-branch]
*/
gulp.task('build-dist', done => {
if (!$.which('git')) {
$.echo('This command requires git')
$.exit(1)
}
// Go to _build
if (!$.test('-e', '_build')) {
$.mkdir('_build')
}
$.cd('_build')
// Clone release/prod branch of vscode-website
// If it exists, upgrade to latest
if (!$.test('-e', 'vscode-website')) {
$.exec(`git clone --depth=1 --branch=release/prod ${URL}`)
} else {
$.cd('vscode-website')
$.exec('git pull origin release/prod')
$.cd('..')
}
// Copy over MD/asset files
$.mkdir('vscode-website/vscode-docs')
$.cp('-R', ['../blogs', '../docs', '../images', '../release-notes', '../remote-release-notes', '../learn', '../build', '../api'], 'vscode-website/vscode-docs')
// Go to vscode-website
$.cd('vscode-website')
// Run setup to fetch vscode-website-dist
$.echo('BRANCH is ' + BRANCH)
const setup = $.exec(`scripts/setup.sh ${GITHUB_TOKEN} ${BRANCH}`)
if (setup.code !== 0) {
console.log('Failed to setup')
done(setup.stderr)
}
// Run build to sync changes to vscode-website-dist
const build = $.exec(`scripts/build.sh ${BRANCH}`)
if (build.code !== 0) {
console.log('Failed to build')
done(build.stderr)
}
done()
})