docs: reinstate Jenkins deployment of docs

This commit is contained in:
fryorcraken.eth 2022-09-09 10:16:13 +10:00
parent 4d29698128
commit 01baf4b6e6
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
3 changed files with 95 additions and 0 deletions

45
ci/Jenkinsfile.gh-pages Normal file
View File

@ -0,0 +1,45 @@
pipeline {
agent { label 'linux' }
options {
disableConcurrentBuilds()
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '20',
daysToKeepStr: '30',
))
}
environment {
GIT_AUTHOR_NAME = 'status-im-auto'
GIT_AUTHOR_EMAIL = 'auto@status.im'
PUPPETEER_SKIP_DOWNLOAD = 'true'
}
stages {
stage('Deps') {
steps {
sh 'npm ci'
}
}
stage('Build') {
steps {
sh 'npm run build'
sh 'npm run doc'
}
}
stage('Publish') {
when { expression { GIT_BRANCH.endsWith('master') } }
steps { script {
sshagent(credentials: ['status-im-auto-ssh']) {
sh 'npm run deploy'
}
} }
}
}
post {
always { cleanWs() }
}
}

11
ci/README.md Normal file
View File

@ -0,0 +1,11 @@
# Description
Configuration of CI builds executed under a Jenkins instance at https://ci.status.im/.
# Website
The `Jenkinsfile.gh-pages` file builds the documentation site with this job:
https://ci.status.im/job/website/job/js-waku.wakuconnect.dev/
And deploys it via `gh-pages` branch and [GitHub Pages](https://pages.github.com/) to:
https://js-waku.wakuconnect.dev/

39
ci/deploy.js Normal file
View File

@ -0,0 +1,39 @@
const { promisify } = require('util')
const { publish } = require('gh-pages')
const ghpublish = promisify(publish)
/* fix for "Unhandled promise rejections" */
process.on('unhandledRejection', err => { throw err })
const Args = process.argv.slice(2)
const USE_HTTPS = Args[0] && Args[0].toUpperCase() === 'HTTPS'
const branch = 'gh-pages'
const org = 'status-im'
const repo = 'js-waku'
/* use SSH auth by default */
let repoUrl = USE_HTTPS
? `https://github.com/${org}/${repo}.git`
: `git@github.com:${org}/${repo}.git`
/* alternative auth using GitHub user and API token */
if (typeof process.env.GH_USER !== "undefined") {
repoUrl = (
'https://' + process.env.GH_USER +
':' + process.env.GH_TOKEN +
'@' + `github.com/${org}/${repo}.git`
)
}
const main = async (url, branch)=> {
console.log(`Pushing to: ${url}`)
console.log(`On branch: ${branch}`)
await ghpublish('build/docs', {
repo: url,
branch: branch,
dotfiles: true,
silent: false
})
}
main(repoUrl, branch)