Charge your APIs Volume 5: Taking APIOps with Continuous Deployment to the Next Level
7.6.2023 | 3 minutes of reading time
In our previous exploration of API Operations (APIOps), we navigated the landscape of "Streamlining your API Operations with Continuous Integration", delving into how this practice can refine our approach towards API development and management. We examined how Continuous Integration (CI), with tools like Vacuum CLI for linting and Portman CLI for testing, can be encapsulated within a reusable GitHub Actions workflow, resulting in seamless and efficient API management.
As we continue our journey, today we venture deeper into the realm of Continuous Deployment (CD). CD is an integral part of APIOps that automates the process of deploying API changes to production, making it a seamless transition from CI. In this post, we will be extending our CI pipeline to a CD pipeline using GitHub Actions while maintaining the use of Vacuum and Portman CLI. Let's dive in!
Continuous Deployment: An In-depth Look
Continuous Deployment takes Continuous Integration a step further. Where CI focuses on automating the integration of code changes and ensuring those changes don’t break the system, CD automates the delivery of those integrated changes to a live environment, ready to be used by end-users. This process facilitates a more efficient delivery mechanism, enabling developers to expedite the deployment of new features, enhancements, and fixes.
Step 1: Extending the CI Pipeline
We'll kick things off by extending the CI pipeline that we previously set up to incorporate a deployment stage. This stage is responsible for delivering our tested and validated API changes to a production environment. We will define separate jobs for building (linting and testing) and deploying within our GitHub Actions:
1jobs:
2 build:
3 runs-on: ubuntu-latest
4 steps:
5 - uses: actions/checkout@v2
6 - name: Install Vacuum CLI
7 run: npm install -g vacuum-cli
8 - name: Install Portman CLI
9 run: npm install -g portman
10 - name: Run Vacuum CLI for linting
11 run: vacuum validate ./path-to-your-api-spec-file.yaml
12 - name: Run Portman tests
13 run: portman --cliOptionsFile portman-cli-options.json
Step 2: Defining the Deploy Job
Next up, we need to define the deployment job. This is the part where our tested and validated changes get deployed to the production environment. Here, we deploy the API definition to an unspecified API Gateway:
1deploy:
2 needs: build
3 runs-on: ubuntu-latest
4 steps:
5 - uses: actions/checkout@v2
6 - name: Deploy API Definition
7 run: ./deploy-api-definition.sh
In this example, deploy-api-definition.sh
is a hypothetical script that deploys your API definition to your API gateway.
When it comes to deploying API definitions to an API gateway, the simplest and most direct way is to upload the API definition directly to the gateway. Most modern API gateways support importing API definitions in standard formats like OpenAPI.
However, more complex scenarios or specific use cases may require an additional transformation step using separate tooling. For instance, if the API gateway requires a proprietary format or if you need to map the API definition to specific gateway configurations that aren't directly represented in standard API definition formats.
These transformations could be simple manipulations or might require complex processing and can be done using custom scripts or specialized tooling, depending on the requirements.
Step 3: Making the CD Pipeline Reusable again
Just like with our CI pipeline, we can make our CD pipeline reusable by defining the workflow in a .github/workflows
directory of a public repository, allowing it to be referenced in other repositories. This provides the advantage of propagating good practices across all your projects and teams, further enhancing the development and deployment process.
Conclusion
APIOps and Continuous Deployment go hand in hand in elevating the delivery mechanism of our APIs. Automating the process from code integration to deployment helps deliver high-quality APIs faster and more efficiently. Regardless of whether you are a novice or a veteran in APIOps, this comprehensive dive into Continuous Deployment provides valuable insights that will help streamline your API management efforts. Happy pipelining!
References
GitHub - codecentric/github-apiops-pipeline: An APIOps Pipeline for Github
Charge your APIs Volume 4: Streamlining API Operations with Continuous Integration
More articles
fromDaniel Kocot
Your job at codecentric?
Jobs
Agile Developer und Consultant (w/d/m)
Alle Standorte
More articles in this subject area
Discover exciting further topics and let the codecentric world inspire you.
Gemeinsam bessere Projekte umsetzen.
Wir helfen deinem Unternehmen.
Du stehst vor einer großen IT-Herausforderung? Wir sorgen für eine maßgeschneiderte Unterstützung. Informiere dich jetzt.
Hilf uns, noch besser zu werden.
Wir sind immer auf der Suche nach neuen Talenten. Auch für dich ist die passende Stelle dabei.
Blog author
Daniel Kocot
Senior Solution Architect / Head of API Consulting
Do you still have questions? Just send me a message.
Do you still have questions? Just send me a message.