From 7267437835d8b7a0bbbe36a73675ce00058b71b3 Mon Sep 17 00:00:00 2001 From: Michael Wittwer Date: Fri, 26 Oct 2018 09:35:38 +0200 Subject: [PATCH 1/3] build(travis): update deploy doc step only deploy docs if job was triggered from master branch --- tools/gh-pages-publish.ts | 61 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/tools/gh-pages-publish.ts b/tools/gh-pages-publish.ts index 879bee26c..32fea3a6a 100644 --- a/tools/gh-pages-publish.ts +++ b/tools/gh-pages-publish.ts @@ -1,31 +1,38 @@ -const { cd, exec, echo, touch } = require("shelljs") -const { readFileSync } = require("fs") -const url = require("url") +const { cd, exec, echo, touch } = require('shelljs') +const { readFileSync } = require('fs') +const url = require('url') -let repoUrl -let pkg = JSON.parse(readFileSync("package.json") as any) -if (typeof pkg.repository === "object") { - if (!pkg.repository.hasOwnProperty("url")) { - throw new Error("URL does not exist in repository section") +const branchName = process.env.TRAVIS_BRANCH +echo(`running on branch ${branchName}`) + +if (branchName === 'master') { + const pkg = JSON.parse(readFileSync('package.json') as any) + let repoUrl + if (typeof pkg.repository === 'object') { + if (!pkg.repository.hasOwnProperty('url')) { + throw new Error('URL does not exist in repository section') + } + repoUrl = pkg.repository.url + } else { + repoUrl = pkg.repository } - repoUrl = pkg.repository.url -} else { - repoUrl = pkg.repository -} -let parsedUrl = url.parse(repoUrl) -let repository = (parsedUrl.host || "") + (parsedUrl.path || "") -let ghToken = process.env.GH_TOKEN + const parsedUrl = url.parse(repoUrl) + const repository = (parsedUrl.host || '') + (parsedUrl.path || '') + const ghToken = process.env.GH_TOKEN -echo("Deploying docs!!!") -cd("dist/docs") -touch(".nojekyll") -exec("git init") -exec("git add .") -exec('git config user.name "Michael Wittwer"') -exec('git config user.email "michael.wittwer@shiftcode.ch"') -exec('git commit -m "docs(docs): update gh-pages"') -exec( - `git push --force --quiet "https://${ghToken}@${repository}" master:gh-pages` -) -echo("Docs deployed!!") + echo('Deploying docs!!!') + cd('dist/docs') + touch('.nojekyll') + exec('git init') + exec('git add .') + exec('git config user.name "Michael Wittwer"') + exec('git config user.email "michael.wittwer@shiftcode.ch"') + exec('git commit -m "docs(docs): update gh-pages"') + exec( + `git push --force --quiet "https://${ghToken}@${repository}" master:gh-pages` + ) + echo('Docs deployed!!') +} else { + echo('Not running on master, therefor docs are not deployed') +} From 3a9989938d61748869fc25beb34e552121e81cb3 Mon Sep 17 00:00:00 2001 From: Michael Wittwer Date: Fri, 26 Oct 2018 09:47:04 +0200 Subject: [PATCH 2/3] build(travis): update deploy doc step update logic --- tools/gh-pages-publish.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/gh-pages-publish.ts b/tools/gh-pages-publish.ts index 32fea3a6a..5ca9dc1cc 100644 --- a/tools/gh-pages-publish.ts +++ b/tools/gh-pages-publish.ts @@ -2,10 +2,14 @@ const { cd, exec, echo, touch } = require('shelljs') const { readFileSync } = require('fs') const url = require('url') -const branchName = process.env.TRAVIS_BRANCH -echo(`running on branch ${branchName}`) +const info = { + TRAVIS_BRANCH: process.env.TRAVIS_BRANCH, + TRAVIS_PULL_REQUEST: process.env.TRAVIS_PULL_REQUEST, + TRAVIS_PULL_REQUEST_BRANCH: process.env.TRAVIS_PULL_REQUEST_BRANCH, +} +echo(`running on branch ${JSON.stringify(info)}`) -if (branchName === 'master') { +if (info.TRAVIS_BRANCH === 'master' && info.TRAVIS_PULL_REQUEST === 'false') { const pkg = JSON.parse(readFileSync('package.json') as any) let repoUrl if (typeof pkg.repository === 'object') { @@ -34,5 +38,5 @@ if (branchName === 'master') { ) echo('Docs deployed!!') } else { - echo('Not running on master, therefor docs are not deployed') + echo('Not running on master -> skipping docs deployment') } From 8e3fe7be4ec4e665f102c6c06e9180bc989907b0 Mon Sep 17 00:00:00 2001 From: Michael Wittwer Date: Fri, 26 Oct 2018 11:19:03 +0200 Subject: [PATCH 3/3] build(travis): build on all branches we need other branches to build too so PR can be checked --- .releaserc.yml | 3 --- .travis.yml | 5 ----- 2 files changed, 8 deletions(-) diff --git a/.releaserc.yml b/.releaserc.yml index ab8ecdf82..77a74f108 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -1,4 +1 @@ branch: master -publishConfig: -# FIXME this does not work - tag: next diff --git a/.travis.yml b/.travis.yml index f2b72f021..4f2803bb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,6 @@ language: node_js node_js: - lts/* -branches: - only: - - master - - /^greenkeeper/.*$/ - cache: directories: - $HOME/.npm