select hexo config based on branch, disallow indexing for develop
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
a0be63357f
commit
0aca6c36d4
|
@ -30,8 +30,15 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
stage('Robot') {
|
||||
when { expression { !GIT_BRANCH.endsWith('master') } }
|
||||
steps { script {
|
||||
sh 'echo "Disallow: /" >> public/robots.txt'
|
||||
} }
|
||||
}
|
||||
|
||||
stage('Publish Prod') {
|
||||
when { expression { env.GIT_BRANCH ==~ /.*master/ } }
|
||||
when { expression { GIT_BRANCH.endsWith('master') } }
|
||||
steps { script {
|
||||
sshagent(credentials: ['status-im-auto-ssh']) {
|
||||
sh 'npm run deploy'
|
||||
|
@ -40,7 +47,7 @@ pipeline {
|
|||
}
|
||||
|
||||
stage('Publish Devel') {
|
||||
when { expression { env.GIT_BRANCH ==~ /.*develop/ } }
|
||||
when { expression { !GIT_BRANCH.endsWith('master') } }
|
||||
steps { script {
|
||||
sshagent(credentials: ['jenkins-ssh']) {
|
||||
sh '''
|
||||
|
|
|
@ -30,4 +30,4 @@ highlight:
|
|||
|
||||
disqus_shortname: hexojs
|
||||
twitter: ethstatus
|
||||
github: staus-im
|
||||
github: status-im
|
||||
|
|
|
@ -30,4 +30,4 @@ highlight:
|
|||
|
||||
disqus_shortname: hexojs
|
||||
twitter: ethstatus
|
||||
github: staus-im
|
||||
github: status-im
|
||||
|
|
23
gulpfile.js
23
gulpfile.js
|
@ -14,14 +14,23 @@ var minify = require('gulp-minify');
|
|||
let cleanCSS = require('gulp-clean-css');
|
||||
var rename = require("gulp-rename");
|
||||
|
||||
const gitBranch = require('./scripts/git-branch');
|
||||
|
||||
// generate html with 'hexo generate'
|
||||
var hexo = new Hexo(process.cwd(), {});
|
||||
|
||||
const getEnv = function () {
|
||||
return gitBranch() == 'master' ? 'prod' : 'dev'
|
||||
}
|
||||
|
||||
gulp.task('generate', function(cb) {
|
||||
var hexo = new Hexo(process.cwd(), {
|
||||
config: `_config.${getEnv()}.yml`,
|
||||
watch: false,
|
||||
});
|
||||
|
||||
hexo.init().then(function() {
|
||||
return hexo.call('generate', {
|
||||
watch: false
|
||||
});
|
||||
return hexo.call('generate');
|
||||
}).then(function() {
|
||||
return hexo.exit();
|
||||
}).then(function() {
|
||||
|
@ -38,10 +47,10 @@ var config = {
|
|||
src: {
|
||||
scss: './themes/navy/source/scss/*.scss',
|
||||
js: [
|
||||
'./themes/navy/source/js/utils.js',
|
||||
'./themes/navy/source/js/popups.js',
|
||||
'./themes/navy/source/js/main.js',
|
||||
]
|
||||
'./themes/navy/source/js/utils.js',
|
||||
'./themes/navy/source/js/popups.js',
|
||||
'./themes/navy/source/js/main.js',
|
||||
]
|
||||
},
|
||||
dist: {
|
||||
css: './public/css',
|
||||
|
|
|
@ -7,10 +7,9 @@
|
|||
},
|
||||
"scripts": {
|
||||
"clean": "rm -rf public/*",
|
||||
"build": "gulp run && hexo generate",
|
||||
"build": "gulp run",
|
||||
"eslint": "eslint .",
|
||||
"deploy": "hexo deploy",
|
||||
"update-submodules": "git submodule update --recursive --remote"
|
||||
"deploy": "hexo deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"cheerio": "^0.20.0",
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
'use strict'
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const util = require('util')
|
||||
|
||||
function parseBranch(buf) {
|
||||
const match = /ref: refs\/heads\/([^\n]+)/.exec(buf.toString())
|
||||
return match ? match[1] : null
|
||||
}
|
||||
|
||||
function gitHeadPath(cwd) {
|
||||
const filepath = path.join(process.cwd(), '.git/HEAD')
|
||||
if (!fs.existsSync(filepath)) {
|
||||
throw new Error('.git/HEAD does not exist')
|
||||
}
|
||||
return filepath
|
||||
}
|
||||
|
||||
const gitBranch = function() {
|
||||
return parseBranch(fs.readFileSync(gitHeadPath()))
|
||||
}
|
||||
|
||||
module.exports = gitBranch
|
Loading…
Reference in New Issue