Skip to content

Commit

Permalink
Merge pull request #384 from hickeyma/fix-ibm-cloud-deployment
Browse files Browse the repository at this point in the history
Fix deployment to IBM Cloud
  • Loading branch information
hickeyma committed Dec 7, 2018
2 parents e41687b + c78578b commit fa88a86
Show file tree
Hide file tree
Showing 10 changed files with 835 additions and 1 deletion.
171 changes: 171 additions & 0 deletions .bluemix/deploy.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
35 changes: 35 additions & 0 deletions .bluemix/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions .bluemix/locales.yml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions .bluemix/nls/messages.yml
Original file line number Diff line number Diff line change
@@ -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"

84 changes: 84 additions & 0 deletions .bluemix/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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
Binary file added .bluemix/toolchain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit fa88a86

Please sign in to comment.