-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
72 lines (62 loc) · 1.72 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
64
65
66
67
68
69
70
71
72
var gulp = require("gulp");
var eslint = require("gulp-eslint");
var del = require("del");
var shell = require("gulp-shell");
var pkg = require("./package");
gulp.task("lint", function () {
return gulp.src(
[
"**/*.js",
"!dist/**/*",
"!node_modules/**/*"
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task("clean", function () {
return del.sync("dist");
});
var distribution = [
"bin/**/*",
"config/**/*",
"core/**/*",
"dashboard/**/*",
"node_modules/**/*",
"sources/**/*",
"stats/**/*",
"version/**/*",
"app.js",
"package.json",
"routes.js",
"util/**/*"
];
gulp.task("build", ["clean"], function () {
return gulp
.src(distribution, {"base": "./"})
.pipe(gulp.dest("dist"));
});
gulp.task("docker", function () {
var email = process.env.DOCKER_EMAIL;
var username = process.env.DOCKER_USERNAME;
var password = process.env.DOCKER_PASSWORD;
var imageName = process.env.DOCKER_IMAGE_NAME || "gerritdashboard-server";
var version = pkg.version;
if (!email) {
throw new Error("DOCKER_EMAIL undefined!");
}
if (!username) {
throw new Error("DOCKER_USERNAME undefined!");
}
if (!password) {
throw new Error("DOCKER_PASSWORD undefined!");
}
return shell.task([
`docker build -t ${imageName}:${version} .`,
`docker tag ${imageName}:${version} ${imageName}:latest`,
`docker login -e="${email}" -u="${username}" -p="${password}"`,
`docker push ${imageName}:${version}`,
`docker push ${imageName}:latest`,
])();
});
gulp.task("default", ["lint", "build"]);