Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: update documentation after publishing a release #3526

Merged
merged 1 commit into from May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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`
devoto13 marked this conversation as resolved.
Show resolved Hide resolved

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 }