Skip to content

Commit

Permalink
feat: use two deploy branches for CI builds
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Pentori <[email protected]>
  • Loading branch information
apentori committed Apr 22, 2024
1 parent 3bc7200 commit 69edf6a
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 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,49 +16,41 @@ pipeline {
environment {
GIT_COMMITTER_NAME = 'status-im-auto'
GIT_COMMITTER_EMAIL = '[email protected]'
PROD_SITE = 'nimbus.team'
DEV_SITE = 'dev.nimbus.team'
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"
}
jenkins.genBuildMetaJSON('build/build.json')
}

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

stage('Publish Devel') {
when { expression { env.GIT_BRANCH !=~ /.*master/ } }
steps {
sshagent(credentials: ['jenkins-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
"""
}
}
}
}

}
post {
cleanup { cleanWs() }
}
}

def isMasterBranch() { GIT_BRANCH ==~ /.*master/ }
def deployBranch() { isMasterBranch() ? 'deploy-master' : 'deploy-develop' }
def deployDomain() { isMasterBranch() ? 'nimbus.team' : 'dev.nimbus.team' }

0 comments on commit 69edf6a

Please sign in to comment.