add CI setup for auto deployments

Changes:

* Add `Jenkinsfile` for running in CI
* Install `gh-pages` and `promisify` Node packages
* Add `scripts/deploy.js` that uses `gh-pages`
* Update `README` with new links and comments
* Drop `package-lock.json` in favour of `yarn.lock`
* Added `resources/public/CNAME` set to `simpledapp.status.im`

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-03-31 15:37:46 +02:00 committed by Jakub
parent f1ccdd78d0
commit ef89c3c2f6
7 changed files with 2819 additions and 2408 deletions

54
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,54 @@
pipeline {
agent { label 'linux' }
options {
disableConcurrentBuilds()
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '20',
daysToKeepStr: '30',
))
}
environment {
SCP_OPTS = 'StrictHostKeyChecking=no'
GH_USER = 'status-im-auto'
GH_MAIL = 'auto@status.im'
}
stages {
stage('Git Prep') {
steps {
sh "git config user.name ${env.GH_USER}"
sh "git config user.email ${env.GH_MAIL}"
}
}
stage('Install Deps') {
steps {
sh 'yarn install --ignore-optional'
}
}
stage('Compile') {
steps {
sh 'yarn run compile'
}
}
stage('Build') {
steps {
sh 'yarn run build'
}
}
stage('Deploy') {
steps {
sshagent(credentials: ['status-im-auto-ssh']) {
sh 'yarn run deploy'
}
}
}
}
post {
always {
sh 'yarn run clean'
}
}
}

View File

@ -1,12 +1,12 @@
# status-dapp
# Desription
Simple Dapp
Status Simple Dapp is a helper Dapp for developers and testers of Status App.
### Installation:
```
npm install
npm run build
yarn install
yarn run build
```
## Development Mode
@ -26,7 +26,7 @@ Wait a bit, then browse to [http://localhost:3449](http://localhost:3449).
### Build CLJS:
```
lein build-prod
yarn run compile
```
Open `resources/public/index.html` in the browser.
@ -34,6 +34,15 @@ Open `resources/public/index.html` in the browser.
### Deploy
```
lein build-prod
cp resources/public/js/compiled/app.js ../status-im.github.io/src/dapp/js/compiled/app.js
```
yarn run deploy
```
## Continuous Integration
Status Jenkins instance builds the `master` branch with this job:
https://ci.status.im/job/misc/job/simpledapp.status.im/
Which deploys it to `gh-pages` branch which is published at:
* https://simpledapp.status.im/

2398
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,14 @@
{
"name": "status-dapp",
"name": "simple-dapp",
"version": "0.0.1",
"license": "MIT",
"homepage": "https://github.com/status-im/simple-dapp",
"scripts": {
"watch": "webpack -d --watch",
"build": "webpack -p"
"compile": "lein build-prod",
"build": "webpack -p",
"deploy": "node scripts/deploy.js",
"clean": "git clean -fxd public"
},
"dependencies": {
"react": "^16.2.0",
@ -13,6 +16,8 @@
"react-native-web": "^0.3.0-rc.4"
},
"devDependencies": {
"gh-pages": "^2.2.0",
"promisify": "^0.0.3",
"webpack": "^3.10.0"
}
}

1
resources/public/CNAME Normal file
View File

@ -0,0 +1 @@
simpledapp.status.im

34
scripts/deploy.js Executable file
View File

@ -0,0 +1,34 @@
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 branch = 'gh-pages'
const org = 'status-im'
const repo = 'simple-dapp'
/* use SSH auth by default */
var repoUrl = `git@github.com:${org}/${repo}.git`
/* alternative auth using GitHub user and API token */
if (process.env.GH_TOKEN != 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('resources/public', {
repo: url,
branch: branch,
dotfiles: true,
silent: false
})
}
main(repoUrl, branch)

2706
yarn.lock Normal file

File diff suppressed because it is too large Load Diff