Skip to content

Instantly share code, notes, and snippets.

@csantanapr
Last active May 30, 2018 21:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csantanapr/addd6f60d3a2ca4f2118806a35f03d7e to your computer and use it in GitHub Desktop.
Save csantanapr/addd6f60d3a2ca4f2118806a35f03d7e to your computer and use it in GitHub Desktop.
Using serverless framework and ibm cloud functions CLI bx wsk
#!/bin/bash
set -e
#Choose command to use to deploy repo (script, wskdeploy, serverless, etc.)
#WSK_DEPLOY="wskdeploy"
WSK_DEPLOY="serverless deploy"
# To create BX_KEY value run: bx iam api-key-create MyKey (save the secret value as it can't be retrieved)
BX_KEY=AAAABBBB123456
BX_ORG=MyOrg
BX_SPACE_DEV=dev
BX_SPACE_PROD=prod
# To ge the account number run: bx account org-account $BX_ORG
BX_ACCOUNT=123456
BX_RESOURCE_GROUP=default
WSK_CONFIG_FILE_DEV=wskdev.properties
WSK_CONFIG_FILE_PROD=wskprod.properties
# Login into bx using api key
bx login -a api.ng.bluemix.net --apikey "${BX_KEY}"
# Setup default account and resource
bx target -c "${BX_ACCOUNT}" -g "${BX_RESOURCE_GROUP}"
# Deploy to dev
# Switch to dev space
bx target -o "${BX_ORG}" -s "${BX_SPACE_DEV}"
# Setup WSK_CONFIG_FILE as environment variable for both bx wsk to write and for serveless to deploy
export WSK_CONFIG_FILE=${WSK_CONFIG_FILE_DEV}
# Run a bx wsk to write auth into WSK_CONFIG_FILE for space
bx wsk api list
#cat ${WSK_CONFIG_FILE}
echo deploying to "${BX_ORG}"_"${BX_SPACE_DEV}"
# Deploy using the deploy command, it will use the new info from WSK_CONFIG_FILE written by bx wsk api list
${WSK_DEPLOY}
# Deploy to prod
# Switch to prod space
bx target -o "${BX_ORG}" -s "${BX_SPACE_PROD}"
# Setup WSK_CONFIG_FILE as environment variable for both bx wsk to write and for serveless to deploy
export WSK_CONFIG_FILE=${WSK_CONFIG_FILE_PROD}
# Run a bx wsk to write auth into WSK_CONFIG_FILE for space
bx wsk api list
#cat ${WSK_CONFIG_FILE}
echo deploying to "${BX_ORG}"_"${BX_SPACE_PROD}"
# Deploy using the deploy comamnd, it will use the new info from WSK_CONFIG_FILE written by bx wsk api list
${WSK_DEPLOY}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment