2017-12-04 17:42:07 -05:00
|
|
|
const sh = require('shelljs');
|
2018-01-24 13:47:07 -05:00
|
|
|
const semver = require('semver');
|
2022-04-06 11:34:18 -04:00
|
|
|
const path = require('path');
|
2017-12-04 17:42:07 -05:00
|
|
|
|
2018-01-24 13:47:07 -05:00
|
|
|
const GIT_LOG = `git log --format=%B -n 1 ${process.env.COMMIT_REF}`;
|
2019-08-30 14:14:53 -04:00
|
|
|
const output = sh.exec(GIT_LOG, {async: false, silent: true}).stdout;
|
2018-01-05 16:42:11 -05:00
|
|
|
|
2021-01-19 18:47:48 -05:00
|
|
|
// if we're on main branch and not on a tagged commit,
|
2017-12-04 17:42:07 -05:00
|
|
|
// error the build so it doesn't redeploy the docs
|
2021-01-19 18:47:48 -05:00
|
|
|
if (process.env.BRANCH === 'main' && semver.valid(output.trim()) === null) {
|
2017-12-04 17:42:07 -05:00
|
|
|
process.exit(1);
|
|
|
|
} else {
|
|
|
|
sh.exec('npm run docs:api');
|
|
|
|
sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');
|
2022-04-06 11:34:18 -04: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-04 17:42:07 -05:00
|
|
|
}
|