2017-12-05 00:42:07 +02:00
|
|
|
const sh = require('shelljs');
|
2018-01-24 20:47:07 +02:00
|
|
|
const semver = require('semver');
|
2019-08-30 20:14:53 +02:00
|
|
|
const generateExample = require('./generate-example.js').generateExample;
|
2017-12-05 00:42:07 +02:00
|
|
|
|
2018-01-24 20:47:07 +02:00
|
|
|
const GIT_LOG = `git log --format=%B -n 1 ${process.env.COMMIT_REF}`;
|
2019-08-30 20:14:53 +02:00
|
|
|
const output = sh.exec(GIT_LOG, {async: false, silent: true}).stdout;
|
2018-01-05 23:42:11 +02:00
|
|
|
|
2017-12-05 00:42:07 +02:00
|
|
|
// if we're on master branch and not on a tagged commit,
|
|
|
|
// error the build so it doesn't redeploy the docs
|
2018-01-24 20:47:07 +02:00
|
|
|
if (process.env.BRANCH === 'master' && semver.valid(output.trim()) === null) {
|
2017-12-05 00:42:07 +02:00
|
|
|
process.exit(1);
|
|
|
|
|
|
|
|
// if we're on any other branch, we can regenerate docs
|
|
|
|
} else {
|
2018-12-01 00:53:08 +02:00
|
|
|
if (process.env.BRANCH !== 'master') {
|
|
|
|
// generate the example
|
|
|
|
generateExample();
|
|
|
|
}
|
|
|
|
|
2017-12-05 00:42:07 +02:00
|
|
|
// generate the docs
|
|
|
|
sh.exec('npm run docs:api');
|
|
|
|
|
|
|
|
// copy the legacy docs over
|
|
|
|
sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');
|
2018-01-30 18:17:41 +02:00
|
|
|
|
2017-12-05 00:42:07 +02:00
|
|
|
}
|