This repository was archived by the owner on Mar 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeploy-gh-pages.js
More file actions
49 lines (42 loc) · 1.79 KB
/
deploy-gh-pages.js
File metadata and controls
49 lines (42 loc) · 1.79 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
43
44
45
46
47
48
49
const { cd, cp, exec, mkdir, rm } = require('shelljs');
const path = require('path');
const fs = require('fs');
const dist = path.resolve(__dirname, 'dist');
const esdoc = path.resolve(__dirname, 'esdoc');
const report = path.resolve(__dirname, 'report');
const samples = path.resolve(__dirname, 'samples');
const coverage = path.resolve(__dirname, 'coverage');
const { GH_TOKEN, TRAVIS_REPO_SLUG } = process.env;
// Copy dist
mkdir('-p', path.join(esdoc, 'dist'));
cp('-r', dist, path.resolve(esdoc));
// Copy samples
mkdir('-p', path.join(esdoc, 'samples'));
cp('-r', samples, path.resolve(esdoc));
// Copy test report
mkdir('-p', path.join(esdoc, 'report'));
const files = fs.readdirSync(report);
const htmlFiles = files.filter(file => path.extname(file) === '.html');
const index = fs.createWriteStream(path.join(esdoc, 'report', 'index.html'));
index.write('<html><body><ul>');
htmlFiles.forEach((file) => {
cp(path.join(report, file), path.join(esdoc, 'report', file));
index.write(`<li><a href='${file}'>${file}</a></li>`);
});
index.write('</ul></body></html>');
index.end();
// Copy coverage report
mkdir('-p', path.join(esdoc, 'coverage'));
cp('-r', path.join(coverage, 'html', '*'), path.join(esdoc, 'coverage'));
// Copy bundle analysis report
mkdir('-p', path.join(esdoc, 'analysis'));
cp(path.join(__dirname, 'bundleAnalysis.html'), path.join(esdoc, 'analysis', 'index.html'));
cp(path.join(__dirname, 'bundleAnalysis.json'), path.join(esdoc, 'analysis', 'stats.json'));
// deploy gh pages
cd(esdoc);
exec('git init');
exec('git config user.name "webcomOps"');
exec('git config user.email "webcom.ops@orange.com"');
exec('git add .');
exec('git commit -m "Deploy to GitHub Pages"');
exec(`git push --force --quiet "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" master:gh-pages > /dev/null 2>&1`);