Skip to content

Commit

Permalink
feat: use two deploy branches for CI builds
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarthkay committed Jul 16, 2024
1 parent 7671854 commit 9e143bc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
39 changes: 18 additions & 21 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env groovy
library '[email protected]'

pipeline {
agent { label 'linux' }

Expand All @@ -13,44 +16,34 @@ pipeline {
environment {
GIT_COMMITTER_NAME = 'status-im-auto'
GIT_COMMITTER_EMAIL = '[email protected]'
PROD_SITE = 'logos.co'
DEV_SITE = 'dev.logos.co'
DEV_HOST = '[email protected]'
SCP_OPTS = 'StrictHostKeyChecking=no'
}

stages {
stage('Install') {
steps {
sh "yarn install"
sh 'yarn install'
}
}

stage('Build') {
steps {
sh 'yarn build'
sh "echo ${env.PROD_SITE} > build/CNAME"
}
}

stage('Publish Prod') {
when { expression { env.GIT_BRANCH ==~ /.*master/ } }
steps {
sshagent(credentials: ['status-im-auto-ssh']) {
sh "ghp-import -p build"
script {
sh 'yarn build'
jenkins.genBuildMetaJSON('build/build.json')
}
}
}

stage('Publish Devel') {
when { expression { env.GIT_BRANCH ==~ /.*develop/ } }
stage('Publish') {
steps {
sshagent(credentials: ['jenkins-ssh']) {
sshagent(credentials: ['status-im-auto-ssh']) {
sh """
rsync -e 'ssh -o ${SCP_OPTS}' -r --delete build/. \
${env.DEV_HOST}:/var/www/${env.DEV_SITE}/
ghp-import \
-b ${deployBranch()} \
-c ${deployDomain()} \
-p build
"""
}
}
}
}
}
Expand All @@ -59,3 +52,7 @@ pipeline {
cleanup { cleanWs() }
}
}

def isMasterBranch() { GIT_BRANCH ==~ /.*master/ }
def deployBranch() { isMasterBranch() ? 'deploy-master' : 'deploy-develop' }
def deployDomain() { isMasterBranch() ? 'logos.co' : 'dev.logos.co' }
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ $ yarn serve

## CI/CD

- The `master` branch is automatically deployed to the production server (e.g., logos.co) through [CI](https://ci.infra.status.im)
- 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/logos.co/) `master` and pushes to `deploy-master` branch, which is hosted at <https://logos.co//>.
- [CI builds](https://ci.infra.status.im/job/website/job/dev.logos.co/) `develop` and pushes to `deploy-develop` branch, which is hosted at <https://dev.logos.co//>.

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
Expand Down

0 comments on commit 9e143bc

Please sign in to comment.