2018-07-03 20:14:07 +03:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const ghpages = require('gh-pages')
|
2019-02-04 23:35:41 +03:00
|
|
|
const {GITHUB_ACTOR, GITHUB_TOKEN} = process.env
|
2018-07-03 20:14:07 +03:00
|
|
|
|
2019-02-04 23:35:41 +03:00
|
|
|
if (GITHUB_TOKEN) {
|
|
|
|
console.error('Publish storybook: No GITHUB_TOKEN found for storybook publishing.')
|
2018-07-03 20:27:31 +03:00
|
|
|
process.exitCode = 1
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-02-04 23:35:41 +03:00
|
|
|
ghpages.publish('build', {
|
2018-07-03 20:14:07 +03:00
|
|
|
branch: 'gh-pages',
|
2019-02-04 23:35:41 +03:00
|
|
|
repo: `https://${GITHUB_ACTOR}:${process.env.GITHUB_TOKEN}@github.com/primer/storybook.git`,
|
2018-07-03 21:21:41 +03:00
|
|
|
user: {
|
|
|
|
name: 'Primer CSS',
|
|
|
|
email: 'design-systems@github.com'
|
|
|
|
}
|
2019-02-04 23:35:41 +03:00
|
|
|
}, error => {
|
|
|
|
if (error) {
|
|
|
|
console.error('gh-pages failed to publish:', error.message.replace(process.env.GITHUB_TOKEN, '[secret]'))
|
2018-07-03 20:22:36 +03:00
|
|
|
process.exitCode = 1
|
2018-07-03 20:14:07 +03:00
|
|
|
}
|
|
|
|
})
|