API Connect

 View Only

Automatically publish your API when you push to github

By Ricky Moorhouse posted Wed December 16, 2015 05:56 PM

  
With the new API Management beta I was able to update my project really quickly to automatically publish my API in API Management – Here’s the steps…

  • Sign up for the new API Management beta, just click through to ‘Cloud’ and login with your IBMID (If you don’t have one you can create one) and once you’ve accepted the terms and conditions your organisation will be created.

  • Install and configure the new toolkit CLI:
    npm install -g https://beta.apim.ibmcloud.com/apimanager/toolkit/apim.toolkit
    apim config:set server=beta.apim.ibmcloud.com
    apim login


  • Create a product definition for your API:
    apim create --type product --title "Travel Information" --apis product.yaml


  • Adjust the product definition as needed in your favourite editor (my product definition)

  • Add the x-ibm-configuration extensions to your swagger document to configure what happens when someone calls the API – in my case invoke the backend API
    x-ibm-configuration:
    enforced: true
    phase: realized
    testable: true
    cors:
    enabled: true
    assembly:
    execute:
    - invoke:
    title: invoke
    target-url: 'backend url'
    (full file)


  • Now switch over to your CodeShip account, load your project and go to the Deployment section of your project.

  • Add a custom script option and configure the following script (adding your details as needed):
    npm install -g https://beta.apim.ibmcloud.com/apimanager/toolkit/apim.toolkit
    apim config:set server=beta.apim.ibmcloud.com
    apim login -u USERNAME -p PASSWORD apim config:set organization=
    apim push docs/swagger.yaml
    apim stage --catalog=sb docs/travel-information.yaml
    apim publish --catalog=sb docs/travel-information.yaml


  • Commit and push to your repository and your updated API will be pushed to API Management! – Here is my example API


If you don’t already have a CodeShip account you can sign up to CodeShip with your github account and create link in your github repository. You can then set up the tests and deployment steps in the project settings.



(This post originally appeared at http://blog.rickymoorhouse.co.uk/2015/12/12/automatically-publish-your-api-when-you-push-to-github/)



Find out more about the IBM API Management vNext Beta and sign up for free to explore new ways to manage your APIs. To view our tutorials and other helpful videos click here.



Follow IBM API Management @ibmapimgt to learn about the newest product updates, upcoming events and more.







0 comments
9 views

Permalink