← Back to Blog

Automatically Deploying a Service on Bizfly App Engine Using GitLab CI

In this post I'll walk you through integrating the new Webhook Deploy feature on Bizfly App Engine to automatically deploy an application using GitLab CI.

This post will be really useful if you're deploying a Service from a GitLab source. The goal we want to reach: every time you push new code to your GitLab repo, App Engine gets the request and proceeds to deploy the new version from that new source code.

This Webhook Deploy feature helps you:

  • Quickly ship a new version to users
  • Automate the update process

In this post I'll walk through the simplest way to integrate it to avoid confusion — if you need to apply it to a more complex case and aren't sure how, feel free to comment below and I'll help.

Step 1: Enable the Webhook Deploy feature

To enable the Webhook Deploy feature, go to your Service on Bizfly App Engine and choose Details.

This page contains info about your service, including Webhook Deploy. Click the toggle in the Webhook Deploy section to enable this feature. It's off by default.

Once you enable the Webhook Deploy feature, you'll get a Webhook URL. This is the URL you'll use to send a POST request to, to deploy a new version of your service.

The system authenticates the new-version deployment request using a TOKEN field attached to the request, so make sure you never share this Webhook URL with anyone. Anyone with the Token can request a redeploy of a new version for your service.

You can also hit the button next to the URL to generate a new token. Once you generate a new token, you'll need to update it wherever Webhook Deploy is being used to keep it working.

So after this step, we now have a URL we can call to deploy a new version for the service.

Step 2: Create a secret in your GitLab repo

To integrate Webhook Deploy for your repository on GitLab, you need to create a Secret in the repository to store the Webhook URL, following these steps:

In your repository, choose Settings -> CI/CD -> Variables -> Add variable

Create a new Secret, name it WEBHOOK_URL and enter the value of your service's Webhook URL on Bizfly App Engine, then hit Add variable.

Step 3: Configure GitLab CI for your repo

To enable GitLab CI in your repo, just create a file named .gitlab-ci.yml in your repository with the following content:

stages:                                      # Define the steps that will run
  - deploy

deploy:
    stage: deploy
    image: alpine:latest
    script:
        - apk add curl
        - curl -X POST $WEBHOOK_URL          # Send a POST request to the Webhook deploy
    only:
        - master                             # Only runs on the master branch

The .gitlab-ci.yml file above sends a POST request to your service's Webhook URL on Bizfly App Engine whenever there's a push event to the master branch.

Once configured successfully, you can push code to the master branch to check the result.

In your repository's CI/CD section, you'll see a job named deploy get run, as shown.

Looking at each job's details, you'll see the deploy job ran with a returned status_code of 200, meaning the new-version deployment request succeeded.

Going back to your service's admin page on Bizfly App Engine, you'll see a new version has been deployed.

So from now on, every change on the master branch will automatically get the Service running on App Engine redeployed.

Wrapping up

Thanks for reading all the way through. Bizfly App Engine is a multi-language application deployment platform my team and I have recently been developing — this platform is currently free to deploy applications on, so feel free to create an account and try it out!

Any feedback is very valuable to us — feel free to reach me directly on Telegram to share feedback or request support!

Have thoughts on this?

I'd love to hear your perspective. Send me a message.

Get in touch