Skip to content

Commit

Permalink
ci: update documentation after publishing a release (karma-runner#3526)
Browse files Browse the repository at this point in the history
  • Loading branch information
devoto13 authored and anthony-redFox committed May 5, 2023
1 parent e2b805e commit 49ac26f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -4,6 +4,7 @@
tmp
test
tasks
/tools/
docs
client
logo
Expand Down
3 changes: 2 additions & 1 deletion release.config.js
Expand Up @@ -17,6 +17,7 @@ module.exports = {
'@semantic-release/github'
],
success: [
'@semantic-release/github'
'@semantic-release/github',
'./tools/update-docs'
]
}
24 changes: 24 additions & 0 deletions tools/update-docs.js
@@ -0,0 +1,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 }

0 comments on commit 49ac26f

Please sign in to comment.