feat: use two deploy branches for CI builds
This way we have two branches on GitHub that reflect the state of the website after CI build has finished and pushed. See README. Also adds `/build.json` to the site for easy access to build info. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
344576d76f
commit
600805bb4b
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/env groovy
|
||||||
|
library 'status-jenkins-lib@v1.8.8'
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent { label 'linux' }
|
agent { label 'linux' }
|
||||||
|
|
||||||
|
@ -13,10 +16,6 @@ pipeline {
|
||||||
environment {
|
environment {
|
||||||
GIT_COMMITTER_NAME = 'status-im-auto'
|
GIT_COMMITTER_NAME = 'status-im-auto'
|
||||||
GIT_COMMITTER_EMAIL = 'auto@status.im'
|
GIT_COMMITTER_EMAIL = 'auto@status.im'
|
||||||
PROD_SITE = 'guide.waku.org'
|
|
||||||
DEV_SITE = 'dev-guide.waku.org'
|
|
||||||
DEV_HOST = 'jenkins@node-01.do-ams3.sites.misc.statusim.net'
|
|
||||||
SCP_OPTS = 'StrictHostKeyChecking=no'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
|
@ -27,28 +26,20 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps {
|
steps { script {
|
||||||
sh 'yarn build'
|
sh 'yarn build'
|
||||||
sh "echo ${env.PROD_SITE} > build/CNAME"
|
jenkins.genBuildMetaJSON('build/build.json')
|
||||||
}
|
} }
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Publish Prod') {
|
stage('Publish') {
|
||||||
when { expression { env.GIT_BRANCH ==~ /.*master/ } }
|
|
||||||
steps {
|
steps {
|
||||||
sshagent(credentials: ['status-im-auto-ssh']) {
|
sshagent(credentials: ['status-im-auto-ssh']) {
|
||||||
sh "ghp-import -p build"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Publish Devel') {
|
|
||||||
when { expression { env.GIT_BRANCH ==~ /.*develop/ } }
|
|
||||||
steps {
|
|
||||||
sshagent(credentials: ['jenkins-ssh']) {
|
|
||||||
sh """
|
sh """
|
||||||
rsync -e 'ssh -o ${SCP_OPTS}' -r --delete build/. \
|
ghp-import \
|
||||||
${env.DEV_HOST}:/var/www/${env.DEV_SITE}/
|
-b ${deployBranch()} \
|
||||||
|
-c ${deployDomain()} \
|
||||||
|
-p build
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,3 +50,7 @@ pipeline {
|
||||||
cleanup { cleanWs() }
|
cleanup { cleanWs() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def isMasterBranch() { GIT_BRANCH ==~ /.*master/ }
|
||||||
|
def deployBranch() { isMasterBranch() ? 'deploy-master' : 'deploy-develop' }
|
||||||
|
def deployDomain() { isMasterBranch() ? 'guide.waku.org' : 'dev-guide.waku.org' }
|
||||||
|
|
|
@ -161,12 +161,14 @@ The static files will be created in the `build` directory.
|
||||||
$ yarn serve
|
$ yarn serve
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## CI/CD
|
## CI/CD
|
||||||
|
|
||||||
- The `master` branch is automatically deployed to the production server (e.g., logos.co) through [CI](https://ci.infra.status.im)
|
- [CI builds](https://ci.infra.status.im/job/website/job/guide.waku.org/) `master` and pushes to `deploy-master` branch, which is hosted at <https://guide.waku.org/>.
|
||||||
- The `develop` branch is automatically deployed to the staging server (e.g., dev.logos.co) through [CI](https://ci.infra.status.im)
|
- [CI builds](https://ci.infra.status.im/job/website/job/dev-guide.waku.org/) `develop` and pushes to `deploy-develop` branch, which is hosted at <https://dev-guide.waku.org/>.
|
||||||
|
|
||||||
|
The hosting is done using [Caddy server with Git plugin for handling GitHub webhooks](https://github.com/status-im/infra-misc/blob/master/ansible/roles/caddy-git).
|
||||||
|
|
||||||
|
Information about deployed build can be also found in `/build.json` available on the website.
|
||||||
|
|
||||||
## Change Process
|
## Change Process
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue