Permalink
Browse files

Merge pull request #384 from hickeyma/fix-ibm-cloud-deployment

Fix deployment to IBM Cloud
  • Loading branch information...
hickeyma committed Dec 7, 2018
2 parents e41687b + c78578b commit fa88a860a87cf38d9a1c4007207e6efae4288242
@@ -0,0 +1,171 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"messages": {
"$i18n": "locales.yml"
},
"title": {
"$ref": "#/messages/deploy.title"
},
"description": {
"$ref": "#/messages/deploy.description"
},
"longDescription": {
"$ref": "#/messages/deploy.longDescription"
},
"type": "object",
"properties": {
"prod-region": {
"description": "The bluemix region",
"type": "string"
},
"prod-organization": {
"description": "The bluemix org",
"type": "string"
},
"prod-space": {
"description": "The bluemix space",
"type": "string"
},
"prod-app-name": {
"description": {
"$ref": "#/messages/deploy.appDescription"
},
"type": "string",
"pattern": "\\S"
},
"slack-teamid": {
"description": {
"$ref": "#/messages/deploy.slackTeamId"
},
"type": "string"
},
"slack-apitoken": {
"description": {
"$ref": "#/messages/deploy.slackApiToken"
},
"type": "string"
},
"captcha-secret": {
"description": {
"$ref": "#/messages/deploy.captchaSecret"
},
"type": "string"
},
"captcha-sitekey": {
"description": {
"$ref": "#/messages/deploy.captchaSiteKey"
},
"type": "string"
}

},
"required": [
"prod-region",
"prod-organization",
"prod-space",
"prod-app-name",
"slack-teamid",
"slack-apitoken",
"captcha-secret",
"captcha-sitekey"
],
"form": [
{
"type": "validator",
"url": "/devops/setup/bm-helper/helper.html"
},
{
"type": "text",
"readonly": false,
"title": {
"$ref": "#/messages/deploy.appName"
},
"key": "prod-app-name"
},
{
"type": "table",
"columnCount": 4,
"widths": [
"15%",
"28%",
"28%",
"28%"
],
"items": [
{
"type": "label",
"title": ""
},
{
"type": "label",
"title": {
"$ref": "#/messages/region"
}
},
{
"type": "label",
"title": {
"$ref": "#/messages/organization"
}
},
{
"type": "label",
"title": {
"$ref": "#/messages/space"
}
},
{
"type": "label",
"title": {
"$ref": "#/messages/prodStage"
}
},
{
"type": "select",
"key": "prod-region"
},
{
"type": "select",
"key": "prod-organization"
},
{
"type": "select",
"key": "prod-space",
"readonly": false
}
]
},
{
"type": "text",
"readonly": false,
"title": {
"$ref": "#/messages/deploy.slackTeamId"
},
"key": "slack-teamid"
},
{
"type": "password",
"readonly": false,
"title": {
"$ref": "#/messages/deploy.slackApiToken"
},
"key": "slack-apitoken"
},
{
"type": "password",
"readonly": false,
"title": {
"$ref": "#/messages/deploy.captchaSecret"
},
"key": "captcha-secret"
},
{
"type": "password",
"readonly": false,
"title": {
"$ref": "#/messages/deploy.captchaSiteKey"
},
"key": "captcha-sitekey"
}
]
}
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 88.5 69.6" style="enable-background:new 0 0 88.5 69.6;" xml:space="preserve">
<style type="text/css">
.st0{fill:#C1E6FE;}
.st1{fill:#5898E3;}
.st2{fill:#447ABC;}
</style>
<rect x="21" y="44.6" class="st0" width="46.6" height="21.7"/>
<path class="st0" d="M63.9,45.1c0,9.7-30,17.6-39.8,17.6S6.5,54.8,6.5,45.1s7.9-17.6,17.6-17.6S63.9,35.3,63.9,45.1z"/>
<path class="st0" d="M81.6,45.1c0,9.7-7.9,17.6-17.6,17.6s-35.5-7.9-35.5-17.6S54.3,27.5,64,27.5S81.6,35.3,81.6,45.1z"/>
<ellipse class="st0" cx="43.8" cy="23.7" rx="20.9" ry="19.2"/>
<g id="RdVmQV_1_">
<g>
<path class="st1" d="M43.9,69.6c-6.5,0-13,0.1-19.5,0C14.2,69.4,5,63.1,1.4,53.4C-2.9,41.3,3.2,27.8,15.3,23
c2.4-0.9,3.2-2.2,3.7-4.5c1.4-6.8,5.4-12,11.5-15.3c13.8-7.7,30.3-1,35.3,13.2c0.4,1.2,0.7,2.5,1,3.8c0.1,0.7,0.4,1.1,1.2,1.2
c6.6,1.1,11.9,4.3,15.9,9.5c4.1,5.4,5.7,11.6,4.5,18.3c-1.8,9.7-7.7,16-16.9,19.1c-2.5,0.8-5.2,1.1-7.8,1.2
C56.9,69.7,50.4,69.6,43.9,69.6L43.9,69.6z M46.5,62.6c-0.5-0.6-0.8-1-1.2-1.4c-2.1-2.4-3.7-5.1-4.7-8.1c-0.6-1.8,0.3-3.7,1.9-4.3
c1.9-0.7,3.9,0.2,4.6,2.1c3,8.8,12.8,14.2,22.7,10.9c9.2-3,14.3-13.9,10.5-22.8c-2.9-6.9-8.3-10.5-15.8-11
c-2.3-0.1-4.6-1.6-4.6-4.5c0-1.1-0.1-2.3-0.4-3.3c-1.9-6.7-6.1-11.2-13-12.8C37.8,5.3,29.2,9.9,26,18.1c-1.1,3-1.1,2.9,2,3.3
c5.5,0.7,10.2,3.1,14,7c0.9,0.9,1.3,2,0.7,3.3c-1,2.6-3.9,3.1-6,1.2c-6.2-5.8-15.1-6.6-22.2-2c-9.2,6-10.6,19-2.7,26.7
c3.4,3.3,7.6,5.1,12.4,5.1c6.8,0,13.6,0,20.4,0C45.4,62.7,45.8,62.6,46.5,62.6z"/>
</g>
</g>
<g>
<path class="st2" d="M59.7,69.6C59.7,69.6,59.6,69.6,59.7,69.6c-0.2,0-0.3,0-0.4,0C59.5,69.6,59.6,69.6,59.7,69.6z"/>
<path class="st2" d="M83.7,30.9c-4-5.3-9.3-8.5-15.9-9.5c-0.7-0.1-1-0.5-1.2-1.2c-0.3-1.3-0.5-2.6-1-3.8
C60.7,2.2,44.2-4.5,30.4,3.2c-6,3.4-10,8.5-11.5,15.3c-0.4,1.9-1,3.1-2.6,4c2.6-0.9,5.5-1.5,8.5-1.5c0.4,0,0.9,0,1.3,0
c-1-0.3-0.8-0.9,0-3C29.2,9.7,37.9,5.2,46.6,7.3c6.9,1.6,11.1,6.1,13,12.8c0.3,1.1,0.4,2.2,0.4,3.3c0,2.9,2.3,4.3,4.6,4.5
c7.4,0.4,12.8,4.1,15.8,11c3.8,8.9-1.3,19.7-10.5,22.8c-10,3.3-19.7-2.1-22.8-10.9c-0.7-1.9-2.6-2.7-4.6-2.1
c-1.6,0.6-2.5,2.5-1.9,4.3c1,3,2.6,5.7,4.7,8.1c0.3,0.4,5.1,5.4,14.3,8.4c1.3,0,2.5,0,3.8-0.1c2.6-0.1,5.3-0.4,7.8-1.2
c9.3-3.1,15.1-9.4,16.9-19.1C89.4,42.5,87.7,36.3,83.7,30.9z"/>
</g>
</svg>
@@ -0,0 +1,29 @@
---
root:
$ref: ./nls/messages.yml
de:
$ref: ./nls/messages_de.yml
en-AA:
$ref: ./nls/messages_en_AA.yml
en-RR:
$ref: ./nls/messages_en_RR.yml
en-ZZ:
$ref: ./nls/messages_en_ZZ.yml
es:
$ref: ./nls/messages_es.yml
fr:
$ref: ./nls/messages_fr.yml
it:
$ref: ./nls/messages_it.yml
ja:
$ref: ./nls/messages_ja.yml
ko:
$ref: ./nls/messages_ko.yml
pt-BR:
$ref: ./nls/messages_pt_BR.yml
zh:
$ref: ./nls/messages_zh.yml
zh-HK:
$ref: ./nls/messages_zh_HK.yml
zh-TW:
$ref: ./nls/messages_zh_TW.yml
@@ -0,0 +1,30 @@
---
template.name: "Deploy a Slackin server"
template.description: "With this toolchain, you can deploy a Slackin server.This toolchain is preconfigured for continuous delivery, source control, issue tracking, and online editing.\n\nThis toolchain uses tools that are part of the Continuous Delivery service. If an instance of that service isn't already in the selected organization, when you click **Create**, it is automatically added with the free [Lite](/catalog/services/continuous-delivery/) plan selected.\n\nTo get started, click **Create**.\n\nFor step-by-step instructions, follow the [tutorial](https://www.ibm.com/devops/method/tutorials/tutorial_toolchain_flow)."
template.gettingStarted: "**Your toolchain is ready!**"
deploy.title: "Sample Deploy Stage"
deploy.description: "sample toolchain"
deploy.longDescription: "The Delivery Pipeline automates continuous deployment."
deploy.appDescription: "The name of your Slackin server"
deploy.appName: "App name"
deploy.slackTeamId: "Slack Team Name"
deploy.slackApiToken: "Slack Legacy Token"
deploy.captchaSecret: "Google reCaptcha Secret"
deploy.captchaSiteKey: "Google reCaptcha Site Key"
region: "Region"
organization: "Organization"
space: "Space"
prodStage: "Production stage"
headerSVG.issueTracker: "ISSUE TRACKER"
headerSVG.gitHub1: "GitHub"
headerSVG.think: "THINK"
headerSVG.code: "CODE"
headerSVG.deliver: "DELIVER"
headerSVG.run: "RUN"
headerSVG.repository: "REPOSITORY"
headerSVG.gitHub2: "GitHub"
headerSVG.pipeline: "PIPELINE"
headerSVG.bluemix: "BLUEMIX"
headerSVG.ibmCloud: "IBM Cloud"
headerSVG.webIde: "WEB IDE"

@@ -0,0 +1,84 @@
---
stages:
- name: BUILD
inputs:
- type: git
branch: master
service: ${SLACKIN_REPO}
triggers:
- type: commit
jobs:
- name: Build
type: builder
- name: DEPLOY
inputs:
- type: job
stage: BUILD
job: Build
triggers:
- type: stage
properties:
- name: CF_APP_NAME
value: undefined
type: text
- name: APP_URL
value: undefined
type: text
- name: SLACK_SUBDOMAIN
value: ${SLACK_SUBDOMAIN}
- name: SLACK_API_TOKEN
value: ${SLACK_API_TOKEN}
- name: GOOGLE_CAPTCHA_SECRET
value: ${GOOGLE_CAPTCHA_SECRET}
- name: GOOGLE_CAPTCHA_SITEKEY
value: ${GOOGLE_CAPTCHA_SITEKEY}
- name: SLACK_INTERVAL
value: '600000'
jobs:
- name: Blue-Green Deploy
type: deployer
target:
region_id: ${PROD_REGION_ID}
organization: ${PROD_ORG_NAME}
space: ${PROD_SPACE_NAME}
application: ${CF_APP_NAME}
script: |
#!/bin/bash
# Push app
push_app() {
if ! cf push "${CF_APP}" --no-start; then
echo "Error pushing ${CF_APP}."
exit 1
fi
cf set-env ${CF_APP} "SLACK_SUBDOMAIN" ${SLACK_SUBDOMAIN}
cf set-env ${CF_APP} "SLACK_API_TOKEN" ${SLACK_API_TOKEN} > /dev/null
cf set-env ${CF_APP} "GOOGLE_CAPTCHA_SECRET" ${GOOGLE_CAPTCHA_SECRET} > /dev/null
cf set-env ${CF_APP} "GOOGLE_CAPTCHA_SITEKEY" ${GOOGLE_CAPTCHA_SITEKEY} > /dev/null
cf set-env ${CF_APP} "SLACK_INTERVAL" ${SLACK_INTERVAL}
cf start "${CF_APP}"
}
if ! cf app $CF_APP; then
push_app
else
OLD_CF_APP=${CF_APP}-OLD-$(date +"%s")
rollback() {
set +e
if cf app $OLD_CF_APP; then
cf logs $CF_APP --recent
cf delete $CF_APP -f
cf rename $OLD_CF_APP $CF_APP
fi
exit 1
}
set -e
trap rollback ERR
cf rename $CF_APP $OLD_CF_APP
push_app
cf delete $OLD_CF_APP -f
fi
# Export app name and URL for use in later Pipeline jobs
export CF_APP_NAME="$CF_APP"
export APP_URL=http://$(cf app $CF_APP_NAME | grep -e urls: -e routes: | awk '{print $2}')
# View logs
#cf logs "${CF_APP}" --recent
BIN +26.6 KB .bluemix/toolchain.png
Binary file not shown.
Oops, something went wrong.

0 comments on commit fa88a86

Please sign in to comment.