Using GitHub Actions with webMethods API Gateway

07

According to a recent Nordic APIs statistics roundup, over 90% of developers are using APIs and they spend nearly 30% of their time coding APIs. This clearly illustrates how important APIs have become for businesses, but also how much impact they have on the workload of IT professionals.

Our industry has well-established practices for software delivery, such as DevOps, that help reduce the time required to deliver software as well as improve its quality. Which leads to the question how webMethods API Management can be integrated with the tools that support and automate these practices.

In this post I’ll dig into how you can set up an automated CI/CD pipeline for webMethods API Management with the market-leading developer platform GitHub and its software workflow automation platform GitHub Actions.

What is GitHub Actions?

GitHub Actions helps you automate all your software workflows, enabling you to build, test and deploy your code right from within GitHub. You can kick off workflows with any GitHub event. The workflows are declared in yaml and stored within the repository itself.

GitHub provides actions to use within your workflows, but there are many community-developed actions as well. As I’m writing this post, there are more than 10,000 open source actions available on GitHub’s Marketplace.

API lifecycle and Software Delivery

This post fits in a series of technical posts that I announced in New API tools are transforming API Management. In that introduction I used this simple representation of the API Lifecycle.

api_lifecycle_stages_iterative

The API lifecycle is a high level abstraction of the actual delivery process for APIs. Ultimately APIs are software, and our industry has well-established practices like DevOps and CI/CD for software delivery. The next diagram illustrates how the API lifecycle can be mapped to different stakeholders.

CD/CD pipelines typically address at least the automation needs of developers and testers. You could argue that you can cover more, but here I will focus on these two roles.

Automating deployment and releases

Git is a very flexible version control system and there are different options for organising source control and developer collaboration. For this example, I have opted for trunk-based development with git tags for release management. This isn’t a recommendation for trunk-based development, but it is one of the strategies that work well and one I like a lot.

The idea is that all commits go directly into the main branch after passing automated build and tests. There are no long-lived feature or release branches and the main branch is (theoretically) releasable at any time. This is why I have a shared development environment that always has the latest commit from the main branch deployed. To prepare a release, I simply create a git tag, which triggers a deployment of that version on the staging environment. After review and manual approval, the same tag can be deployed to production.

In my example project you can see how I use GitHub Actions workflows that run whenever a commit or tag is pushed. The README is quite elaborate, so I’ll refer you there if you want to understand how it works. webMethods API Gateway comes with an extensive set of APIs that you can use to administer and configure the platform. You will typically want to combine them to suit your specific needs. For this example I have created custom actions for GitHub that help me create and promote APIs.

With commits pushed to the main branch, I have configured the CI/CD workflow to use my Register API action and update the API in the gateway of the shared development environment. It handles creating new APIs, creating new API versions and updating existing versions for me.

When tags are pushed, the CI/CD workflow uses my Promote API action and promotes the API and all associated assets (applications, policies, etc.) to the staging environment and (after review and approval) to the production environment.

If you’d like to see it in action, here is a quick demonstration that takes less than 10 minutes!

youtube

What is next?

Obviously you can do much more with a flexible automation platform like GitHub Actions. You could for example automate publication of the API to webMethods Developer Portal, automate registration of the API with monitoring and analytics platforms, etc. I will keep those for another time though. :wink:

2 Likes

Very cool, Jiri! I can see the npm package you created is getting popular, too. Well done.