Release after every tag push

Buddy lets you automatically build, test and release your application whenever a tag is pushed to the repository. This article will tell you how to configure a delivery pipeline triggered on this condition in Buddy.

Release on tag push

The first step towards deployment automation is adding a new project and selecting the repository from which you want to upload. You can choose GitHub, Bitbucket or GitLab repository, as well as any other custom Git repo: Image loading...Creating a new project

Once the project is synchronized, you can add a new pipeline. The most important thing is to set it up to run only when a new tag is pushed to the repository. To do that, set the trigger mode to On events, click + to add Git push event, then select Wildcard, and customize the refs/tags pattern that will trigger the pipeline.

Tip
For example, setting the pattern to refs/tags/v* will only deploy the tags starting with v, such as v1, v1.1, v2, and so on.

Image loading...Adding a new pipeline

Build Docker image on tag push

After specifying when and for which tags the pipeline will be triggered, we are ready to define what exactly should be executed.

The pipeline below will:

  1. Run unit tests on repository code
  2. Build a Docker image from the tested code
  3. Run the image to check if everything works properly
  4. Push the image to a Docker registry if all steps above have succeeded Image loading...Pipeline example

Run unit tests

The core principle of Continuous Integration is testing every change pushed to the repository, tags included. Buddy lets you automatically test your application before the release with build actions which are basically isolated testing environments. For example, if your application is based on Node, you just need to select Node from the action roster and configure its details: Image loading...Environment customization

Build Docker image

The next step is dockerizing the application. To do that, select the Build Image action from the Docker section. There you need to indicate the Dockerfile in your repository and the build context path (optional): Image loading...Build Docker image action configuration

Run Docker image

Now we need to make sure the Docker image that we built is working okay. For that, we shall use the Run Docker Image action. The action lets you run commands in the selected Docker container. Make sure to select the image built in the previous build action, just as it's shown below: Image loading...Run Docker image environment settings

Push Docker image

The last step is pushing the image to the registry. Select Push image and configure the action details. Buddy has native integrations with Docker Hub, Amazon ECR, and Google GCR. You can also select your own private registry.

Warning
Since we only release tags in this pipeline, make sure to use the $BUDDY_RUN_TAG variable in the Tags to apply field.

Image loading...Push Docker Image action configuration

Last modified on Oct 29, 2024

Recommended