forked from karma-runner/karma
/
update-docs.js
24 lines (18 loc) · 1.01 KB
/
update-docs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { execSync } = require('child_process')
const { dirSync } = require('tmp')
const success = async (pluginConfig, { nextRelease, logger }) => {
const [major, minor] = nextRelease.version.split('.')
const docsVersion = `${major}.${minor}`
const { name: docsPath } = dirSync()
// This is a regular repository remote one would get if they click a Clone
// button on GitHub. The only added part is GH_TOKEN value in the `userinfo`
// part of the URL (https://en.wikipedia.org/wiki/URL), which allows GitHub
// to authenticate a user and authorise the push to the repository.
const repoOrigin = `https://${process.env.GH_TOKEN}@github.com/karma/karma-runner.github.com.git`
const options = { encoding: 'utf8', cwd: docsPath }
logger.log(execSync(`git clone ${repoOrigin} .`, options))
logger.log(execSync('npm ci', options))
logger.log(execSync(`./sync-docs.sh "${nextRelease.gitTag}" "${docsVersion}"`, options))
logger.log(execSync('git push origin master', options))
}
module.exports = { success }