summaryrefslogtreecommitdiff
path: root/javascript/videojs/build/netlify-docs.js
diff options
context:
space:
mode:
Diffstat (limited to 'javascript/videojs/build/netlify-docs.js')
-rw-r--r--javascript/videojs/build/netlify-docs.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/javascript/videojs/build/netlify-docs.js b/javascript/videojs/build/netlify-docs.js
new file mode 100644
index 0000000..e7ef6ad
--- /dev/null
+++ b/javascript/videojs/build/netlify-docs.js
@@ -0,0 +1,23 @@
+const sh = require('shelljs');
+const semver = require('semver');
+const path = require('path');
+
+const GIT_LOG = `git log --format=%B -n 1 ${process.env.COMMIT_REF}`;
+const output = sh.exec(GIT_LOG, {async: false, silent: true}).stdout;
+
+// if we're on main branch and not on a tagged commit,
+// error the build so it doesn't redeploy the docs
+if (process.env.BRANCH === 'main' && semver.valid(output.trim()) === null) {
+ process.exit(1);
+} else {
+ sh.exec('npm run docs:api');
+ sh.cp('-R', 'docs/legacy-docs', 'docs/api/docs');
+
+ // 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'));
+}