Skip to content

Instantly share code, notes, and snippets.

@pheuberger
Created January 24, 2019 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pheuberger/ca0d63862049ee533d1cb317d6e1de30 to your computer and use it in GitHub Desktop.
Save pheuberger/ca0d63862049ee533d1cb317d6e1de30 to your computer and use it in GitHub Desktop.
CI/CD script with the serverless framework on IBM Cloud DevOps toolchain
#!/bin/bash
ibmcloud api --unset
# Login to ibmcloud, generate .wskprops
ibmcloud login --apikey $IBMCLOUD_API_KEY -a $API_ENDPOINT
ibmcloud target -o "$ORG" -s "$SPACE"
ibmcloud fn api list > /dev/null
echo 'Updating node and npm'
export NODE_VERSION=10.8.0
export NVM_VERSION=0.34.0
npm config delete prefix \
&& curl -o- https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh | bash \
&& export NVM_DIR="$HOME/.nvm" \
&& . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default \
&& node -v \
&& npm -v
echo 'Installing dependencies...'
npm install
npm i serverless -g
echo 'Running tests...'
npm test
echo 'Deploying API'
sls deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment