diff --git a/.github/workflows/deploy-gh-pages.yml b/.github/workflows/deploy-gh-pages.yml deleted file mode 100644 index e3f05efa5e..0000000000 --- a/.github/workflows/deploy-gh-pages.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Webchat Deploy GH Pages - -on: - push: - branches: - - 'master' - -jobs: - deploy_gh_pages: - runs-on: ubuntu-latest - steps: - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set git author identity - run: | - git config user.name "GitHub Action On js-waku Repo" - git config user.email "franck+ghpages@status.im" - - - name: Install NodeJS - uses: actions/setup-node@v2 - with: - node-version: '16' - - - name: Cache npm cache - uses: actions/cache@v2 - with: - path: ~/.npm - key: node-v2-${{ hashFiles('**/package-lock.json') }} - - - name: "[js-waku] install using npm ci" - uses: bahmutov/npm-install@v1 - - - name: "[js-waku] build" - run: npm run build - - - name: "[web-chat] install using npm i" - run: npm install - working-directory: examples/web-chat - - - name: "[web-chat] build" - run: npm run build - working-directory: examples/web-chat - - - name: "[web-chat] Deploy on gh pages to /" - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./examples/web-chat/build - - - name: "[eth-pm] install using npm i" - run: npm install - working-directory: examples/eth-pm - - - name: "[eth-pm] build" - run: npm run build - working-directory: examples/eth-pm - - - name: "[eth-pm] Deploy on gh pages to /eth-pm" - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./examples/eth-pm/build - destination_dir: eth-pm - - - name: "[eth-pm-wallet] install using npm i" - run: npm install - working-directory: examples/eth-pm-wallet-encryption - - - name: "[eth-pm-wallet] build" - run: npm run build - working-directory: examples/eth-pm-wallet-encryption - - - name: "[eth-pm-wallet] Deploy on gh pages to /eth-pm-wallet" - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./examples/eth-pm-wallet-encryption/build - destination_dir: eth-pm-wallet - - - name: Generate docs - run: npm run doc:html - - - name: Deploy documentation on gh pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - keep_files: true # Do not delete web chat app - publish_dir: ./build/docs - destination_dir: docs diff --git a/ci/Jenkinsfile.gh-pages b/ci/Jenkinsfile.gh-pages new file mode 100644 index 0000000000..46e3948cbf --- /dev/null +++ b/ci/Jenkinsfile.gh-pages @@ -0,0 +1,40 @@ +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' + } + + stages { + stage('Install Deps') { + steps { + sh 'yarn install' + } + } + + stage('Build') { + steps { + sh 'yarn run doc' + } + } + + stage('Publish Prod') { + when { expression { GIT_BRANCH.endsWith('docs-build') } } + steps { script { + sshagent(credentials: ['status-im-auto-ssh']) { + sh 'yarn run deploy' + } + } } + } + } +} 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 100755 index 0000000000..4ea0be4399 --- /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 (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) diff --git a/package-lock.json b/package-lock.json index 382e45d519..1318dcac7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,7 +57,7 @@ "eslint-plugin-import": "^2.25.3", "eslint-plugin-prettier": "^4.0.0", "fast-check": "^2.14.0", - "gh-pages": "^3.1.0", + "gh-pages": "^3.2.3", "karma": "^6.3.4", "karma-chrome-launcher": "^3.1.0", "karma-mocha": "^2.0.1", diff --git a/package.json b/package.json index c89082e8f7..076803bb61 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,10 @@ "proto:build": "buf generate", "watch:build": "tsc -p tsconfig.json -w", "watch:test": "nyc --silent mocha --watch", - "doc": "run-s doc:html && open-cli build/docs/index.html", + "doc": "run-s doc:*", "doc:html": "typedoc --excludeInternal --listInvalidSymbolLinks --exclude **/*.spec.ts --out build/docs src/", + "doc:cname": "echo 'js-waku.wakuconnect.dev' > build/docs/CNAME", + "deploy": "node ci/deploy.js", "reset-hard": "git clean -dfx && git reset --hard && npm i && npm run build && for d in examples/*; do (cd $d; npm i); done" }, "engines": { @@ -102,7 +104,7 @@ "eslint-plugin-import": "^2.25.3", "eslint-plugin-prettier": "^4.0.0", "fast-check": "^2.14.0", - "gh-pages": "^3.1.0", + "gh-pages": "^3.2.3", "karma": "^6.3.4", "karma-chrome-launcher": "^3.1.0", "karma-mocha": "^2.0.1",