2017-12-05 00:42:07 +02:00
|
|
|
const sh = require('shelljs');
|
2018-01-24 20:47:07 +02:00
|
|
|
const semver = require('semver');
|
2022-04-06 17:34:18 +02:00
|
|
|
const path = require('path');
|
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
|
|
|
|
2021-01-20 01:47:48 +02:00
|
|
|
// if we're on main branch and not on a tagged commit,
|
2017-12-05 00:42:07 +02:00
|
|
|
// error the build so it doesn't redeploy the docs
|
2021-01-20 01:47:48 +02:00
|
|
|
if (process.env.BRANCH === 'main' && semver.valid(output.trim()) === null) {
|
2017-12-05 00:42:07 +02:00
|
|
|
process.exit(1);
|
|
|
|
} else {
|
|
|
|
sh.exec('npm run docs:api');
|
|
|
|
sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');
|
2022-04-06 17:34:18 +02:00
|
|
|
|
|
|
|
// move docs/_redirects into the root of the docs site
|
|
|
|
//
|
|
|
|
// this is needed because the root of the docs site is docs/api, which is not
|
|
|
|
// in version control.
|
|
|
|
const docsPath = path.join(__dirname, '..', 'docs');
|
|
|
|
|
|
|
|
sh.cp(path.join(docsPath, '_redirects'), path.join(docsPath, 'api', '_redirects'));
|
2017-12-05 00:42:07 +02:00
|
|
|
}
|