From 9a1a47d85d985f32438643c55b47286442c88e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 7 May 2024 10:53:18 +0200 Subject: [PATCH] ci: fix Jenkinsfile and update readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use double branch setup with `master`/`develop` being built and pushed as `deploy-master`/`deploy-develop`. Signed-off-by: Jakub SokoĊ‚owski --- Jenkinsfile | 39 +++++++++++++++++---------------------- README.md | 8 +++++--- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 88d659bc..796b9fa5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,6 @@ +#!/usr/bin/env groovy +library 'status-jenkins-lib@v1.8.15' + pipeline { agent { label 'linux' } @@ -13,49 +16,41 @@ pipeline { environment { GIT_COMMITTER_NAME = 'status-im-auto' GIT_COMMITTER_EMAIL = 'auto@status.im' - PROD_SITE = 'docs.codex.storage' - DEV_SITE = 'dev-docs.codex.storage' - DEV_HOST = 'jenkins@node-01.do-ams3.sites.misc.statusim.net' - SCP_OPTS = 'StrictHostKeyChecking=no' } stages { stage('Install') { steps { - sh "yarn install" + sh 'yarn install' } } stage('Build') { - steps { + steps { script { 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 ==~ /.*develop/ } } - 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() ? 'rfc.vac.dev' : 'dev-rfc.vac.dev' } diff --git a/README.md b/README.md index b9b99fb3..336ef3bf 100644 --- a/README.md +++ b/README.md @@ -130,12 +130,14 @@ The static files will be created in the `build` directory. $ 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/rfc.vac.dev/) `master` and pushes to `deploy-master` branch, which is hosted at . +- [CI builds](https://ci.infra.status.im/job/website/job/dev-rfc.vac.dev/) `develop` and pushes to `deploy-develop` branch, which is hosted at . +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