From 365d10edc8c804dc8f231a2e0544edc206b4a3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 2 Sep 2021 20:02:03 +0200 Subject: [PATCH] add Jenkinsfile and deploy.js script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- Jenkinsfile | 66 +++++++++++++++++++++++++++++ README.md | 45 ++++++++++++-------- package.json | 9 +++- scripts/deploy.js | 25 +++++++++++ yarn.lock | 106 +++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 225 insertions(+), 26 deletions(-) create mode 100644 Jenkinsfile create mode 100644 scripts/deploy.js diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..9912a48 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,66 @@ +pipeline { + agent { label 'linux' } + + options { + disableConcurrentBuilds() + /* manage how many builds we keep */ + buildDiscarder(logRotator( + numToKeepStr: '20', + daysToKeepStr: '30', + )) + } + + environment { + SCP_OPTS = 'StrictHostKeyChecking=no' + DEV_HOST = 'jenkins@node-01.do-ams3.proxy.misc.statusim.net' + DEV_SITE = 'dev.vac.dev' + GH_USER = 'status-im-auto' + GH_MAIL = 'auto@status.im' + /* Avoid need for sudo when using bundler. */ + GEM_HOME = "${env.HOME}/.gem" + } + + stages { + stage('Git Prep') { + steps { + sh "git config user.name ${env.GH_USER}" + sh "git config user.email ${env.GH_MAIL}" + sh 'yarn run clean' + } + } + + stage('Install Deps') { + steps { + sh 'yarn install --ignore-optional' + sh 'bundle install' + } + } + + stage('Build') { + steps { + sh 'yarn run build:production' + } + } + + stage('Publish Prod') { + when { expression { env.GIT_BRANCH ==~ /.*master/ } } + steps { + sshagent(credentials: ['status-im-auto-ssh']) { + sh 'yarn run deploy' + } + } + } + + stage('Publish Devel') { + when { expression { !(env.GIT_BRANCH ==~ /.*master/) } } + steps { + sshagent(credentials: ['jenkins-ssh']) { + sh """ + rsync -e 'ssh -o ${SCP_OPTS}' -r --delete _site/. \ + ${env.DEV_HOST}:/var/www/${env.DEV_SITE}/ + """ + } + } + } + } +} diff --git a/README.md b/README.md index bf00fbb..dacddf6 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,34 @@ -# Vac +# Vac.dev Website -## Requirements +Originally created by [EthWorks](https://ethworks.io/). -- [Bundler](http://bundler.io/) -- [Jekyll](https://jekyllrb.com/) -- [Node.js](https://nodejs.org/en/) -- [npm](https://www.npmjs.com/) -- [Ruby](https://www.ruby-lang.org/en/) +# Development -## Get started +* Install Depndencies: + ``` + yarn install + bundles install + ``` +* Build Website + ``` + yarn run build + ``` +* For development or server: + ``` + yarn run dev + yarn run start + ``` -### Setting up bundler and jekyll on Apple M1 (with system installed ruby x86_64) +# Continuous Integration -Running inside project directory: +* `develop` branch is pushed to [dev.vac.dev](https://dev.vac.dev) via [this CI Job](https://ci.status.im/job/website/job/dev.vac.dev/) +* `master` branch is pushed to [vac.dev](https://vac.dev) via [this CI Job](https://ci.status.im/job/website/job/vac.dev/) -- `arch -x86_64 gem install --user-install bundler jekyll` -- `echo 'export PATH="~/.gem/ruby/2.6.0/bin:$PATH"' >> ~/.zshrc` -- `bundle update` +# Known Issues -### Working with the project - -- `bundle install` to install Ruby gems -- `npm ci` to install npm packages listed in `package-lock.json` -- `npm run start` or `npm run dev` to compile the site with development settings and run BrowserSync +### Bundler and Jekyll on Apple M1 (with Ruby `x86_64`) +```sh +arch -x86_64 gem install --user-install bundler jekyll +echo 'export PATH="~/.gem/ruby/2.6.0/bin:$PATH"' >> ~/.zshrc +bundle update +``` diff --git a/package.json b/package.json index 6fc06f5..4692506 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,16 @@ "build:dev": "cross-env NODE_ENV=development gulp", "build": "npm run build:production", "dev": "cross-env NODE_ENV=development gulp serve", - "start": "npm run dev" + "start": "npm run dev", + "clean": "git clean -fdx", + "deploy": "node scripts/deploy.js" }, "repository": { "type": "git", "url": "https://github.com/EthWorks/status-vac.git" }, - "author": "Ethworks" + "author": "Ethworks", + "dependencies": { + "gh-pages": "^3.2.3" + } } diff --git a/scripts/deploy.js b/scripts/deploy.js new file mode 100644 index 0000000..7a60a9c --- /dev/null +++ b/scripts/deploy.js @@ -0,0 +1,25 @@ +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 distDir = '_site' +const branch = 'gh-pages' +const org = 'vacp2p' +const repo = 'vac.dev' +const repoUrl = `git@github.com:${org}/${repo}.git` + +const main = async (url, branch)=> { + console.log(`Pushing to: ${url}`) + console.log(`On branch: ${branch}`) + await ghpublish(distDir, { + repo: url, + branch: branch, + dotfiles: true, + silent: false + }) +} + +main(repoUrl, branch) diff --git a/yarn.lock b/yarn.lock index d65b395..3106a25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -287,11 +287,23 @@ array-sort@^1.0.0: get-value "^2.0.6" kind-of "^5.0.2" +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk= + dependencies: + array-uniq "^1.0.1" + array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== +array-uniq@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + integrity sha1-r2rId6Jcx/dOBYiUdThY39sk/bY= + array-unique@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" @@ -339,6 +351,13 @@ async@1.5.2: resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= +async@^2.6.1: + version "2.6.3" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" + integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + dependencies: + lodash "^4.17.14" + atob@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" @@ -1516,7 +1535,7 @@ colorette@^1.2.2, colorette@^1.3.0: resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.3.0.tgz#ff45d2f0edb244069d3b772adeb04fed38d0a0af" integrity sha512-ecORCqbSFP7Wm8Y6lyqMJjexBQqXSF7SSeaTyGGphogUjBlFP9m9o08wy86HL2uB7fMTxtOUzLMk7ogKcxMg1w== -commander@^2.2.0, commander@^2.8.1: +commander@^2.18.0, commander@^2.2.0, commander@^2.8.1: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -1531,6 +1550,11 @@ commander@^7.2.0: resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== +commondir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" + integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= + component-bind@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" @@ -2169,6 +2193,11 @@ electron-to-chromium@^1.3.47, electron-to-chromium@^1.3.811: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.827.tgz#c725e8db8c5be18b472a919e5f57904512df0fc1" integrity sha512-ye+4uQOY/jbjRutMcE/EmOcNwUeo1qo9aKL2tPyb09cU3lmxNeyDF4RWiemmkknW+p29h7dyDqy02higTxc9/A== +email-addresses@^3.0.1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/email-addresses/-/email-addresses-3.1.0.tgz#cabf7e085cbdb63008a70319a74e6136188812fb" + integrity sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg== + emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" @@ -2583,6 +2612,15 @@ filenamify@^2.0.0: strip-outer "^1.0.0" trim-repeated "^1.0.0" +filenamify@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/filenamify/-/filenamify-4.3.0.tgz#62391cb58f02b09971c9d4f9d63b3cf9aba03106" + integrity sha512-hcFKyUG57yWGAzu1CMt/dPzYZuv+jAJUT85bL8mrXvNe6hWj6yEHEc4EdcgiA6Z3oi1/9wXJdZPXF2dZNgwgOg== + dependencies: + filename-reserved-regex "^2.0.0" + strip-outer "^1.0.1" + trim-repeated "^1.0.0" + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -2613,6 +2651,15 @@ finalhandler@1.1.0: statuses "~1.3.1" unpipe "~1.0.0" +find-cache-dir@^3.3.1: + version "3.3.2" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.2.tgz#b30c5b6eff0730731aea9bbd9dbecbd80256d64b" + integrity sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig== + dependencies: + commondir "^1.0.1" + make-dir "^3.0.2" + pkg-dir "^4.1.0" + find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" @@ -2621,7 +2668,7 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" -find-up@^4.1.0: +find-up@^4.0.0, find-up@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== @@ -2745,6 +2792,15 @@ fs-extra@^10.0.0: jsonfile "^6.0.1" universalify "^2.0.0" +fs-extra@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" + integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-mkdirp-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz#0b7815fc3201c6a69e14db98ce098c16935259eb" @@ -2837,6 +2893,19 @@ get-value@^2.0.3, get-value@^2.0.6: resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= +gh-pages@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/gh-pages/-/gh-pages-3.2.3.tgz#897e5f15e111f42af57d21d430b83e5cdf29472c" + integrity sha512-jA1PbapQ1jqzacECfjUaO9gV8uBgU6XNMV0oXLtfCX3haGLe5Atq8BxlrADhbD6/UdG9j6tZLWAkAybndOXTJg== + dependencies: + async "^2.6.1" + commander "^2.18.0" + email-addresses "^3.0.1" + filenamify "^4.3.0" + find-cache-dir "^3.3.1" + fs-extra "^8.1.0" + globby "^6.1.0" + gifsicle@^5.0.0: version "5.2.0" resolved "https://registry.yarnpkg.com/gifsicle/-/gifsicle-5.2.0.tgz#b06b25ed7530f033f6ed2c545d6f9b546cc182fb" @@ -2898,7 +2967,7 @@ glob-watcher@^5.0.3: normalize-path "^3.0.0" object.defaults "^1.1.0" -glob@^7.0.0, glob@^7.1.1, glob@^7.1.3: +glob@^7.0.0, glob@^7.0.3, glob@^7.1.1, glob@^7.1.3: version "7.1.7" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== @@ -2949,6 +3018,17 @@ globby@^10.0.0: merge2 "^1.2.3" slash "^3.0.0" +globby@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" + integrity sha1-9abXDoOV4hyFj7BInWTfAkJNUGw= + dependencies: + array-union "^1.0.1" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + glogg@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/glogg/-/glogg-1.0.2.tgz#2d7dd702beda22eb3bffadf880696da6d846313f" @@ -3865,6 +3945,13 @@ jsonfile@^3.0.0: optionalDependencies: graceful-fs "^4.1.6" +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + optionalDependencies: + graceful-fs "^4.1.6" + jsonfile@^6.0.1: version "6.1.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" @@ -4021,7 +4108,7 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.17.10, lodash@^4.17.21, lodash@^4.17.4: +lodash@^4.17.10, lodash@^4.17.14, lodash@^4.17.21, lodash@^4.17.4: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -4089,7 +4176,7 @@ make-dir@^1.0.0, make-dir@^1.2.0: dependencies: pify "^3.0.0" -make-dir@^3.0.0: +make-dir@^3.0.0, make-dir@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== @@ -4854,6 +4941,13 @@ pinkie@^2.0.0: resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= +pkg-dir@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + plugin-error@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c" @@ -6102,7 +6196,7 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" -strip-outer@^1.0.0: +strip-outer@^1.0.0, strip-outer@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/strip-outer/-/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631" integrity sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==