From 01baf4b6e63f1355f3e08f520c71b1e9646f5fba Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Fri, 9 Sep 2022 10:16:13 +1000 Subject: [PATCH] docs: reinstate Jenkins deployment of docs --- ci/Jenkinsfile.gh-pages | 45 +++++++++++++++++++++++++++++++++++++++++ ci/README.md | 11 ++++++++++ ci/deploy.js | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 ci/Jenkinsfile.gh-pages create mode 100644 ci/README.md create mode 100644 ci/deploy.js diff --git a/ci/Jenkinsfile.gh-pages b/ci/Jenkinsfile.gh-pages new file mode 100644 index 0000000000..a095b3df8e --- /dev/null +++ b/ci/Jenkinsfile.gh-pages @@ -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() } + } +} diff --git a/ci/README.md b/ci/README.md new file mode 100644 index 0000000000..3a085eb572 --- /dev/null +++ b/ci/README.md @@ -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/ diff --git a/ci/deploy.js b/ci/deploy.js new file mode 100644 index 0000000000..dc8c077c3b --- /dev/null +++ b/ci/deploy.js @@ -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)