Tech Blog

Leveraging the public cloud: Adding a “Deploy” button to your repository

In this contribution to our occasional series on leveraging the public cloud, we’re going to add a “Deploy now” button to our Github repository to enable super-simple deployment of the app we want to share. Our repository’s readme file has instructions for how to install the app and its dependencies and what environment variables must be set for it to work. But deploying the app still takes a bit of work. The power of the public cloud allows us to define machine-readable deployment instructions for our app so that others can easily create a copy and have it up and running in no time.

In a previous blog post, we showed how to get started with Node.js and the Alma REST APIs. The application was simple- given a bar code it uses the Retrieve Item and Scan Item APIs to perform actions on the item. The Github repository includes instructions for how to deploy the app and set the relevant environment variables.

Deploy to Heroku Button

In this exercise, we’re going to add a “Deploy to Heroku” button to our app’s repository. Heroku is a platform-as-a-service company that provides hosting services for applications. They have a free tier for testing and “hobbyists.” Using a custom schema, we can define an app.json file which includes some descriptive metadata and all of the application’s dependencies.

Our app.json is quite simple:

{
  "name": "Simple Node Alma APIs",
  "description": "A simple node application to illustrate using APIs from Ex Libris Alma",
  "repository": "https://github.com/jweisman/simple-node-alma-apis",
  "env": {
    "ALMA_HOST": {
      "description": "URL for the Alma APIs",
      "value": "https://api-na.hosted.exlibrisgroup.com"
    },
    "ALMA_PATH": {
      "description": "Path for the Alma APIs",
      "value": "/almaws/v1"
    },
    "API_KEY": {
      "description": "Your API key. See https://developers.exlibrisgroup.com/alma/apis"
    },
    "WEBHOOK_SECRET": {
      "description": "Used to validate webhooks from Alma. See https://developers.exlibrisgroup.com/alma/integrations/webhooks",
      "required": false
    }
  }
}

Once we’ve checked this file into the root of our repository, we can add a button link to our README.md file:

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

Deploying the App

Now that we have the button available on our Readme file, following the process to deploy the app is simple. After I create a free account on Heroku.com, I click on the Deploy button. The create new app screen is built from the details provided above in the app.json file. I specify the name of my new app, the region to deploy it to, and the environment variables.

Clicking on the “Deploy app” button kicks off a process which results in a newly deploy application in the Heroku environment:

The deployed app

Clicking on the “View” button brings me to a working application with access to data in my Alma environment.

Of course, this process could be done manually, but providing this feature lowers the barrier to entry and makes it even easier to get started with using the Alma APIs in your institution. We will try to add this feature to sample repositories in the future and encourage you to do the same. Other cloud providers offer similar capabilities so you can implement the one(s) that fit with your style and environment.

Leave a Reply