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: 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 push', select 'Tags by wildcard' as the branch, and customize the refs/tags pattern that will trigger the pipeline.

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.

Adding a new pipeline

To learn more about the working principles of pipelines in Buddy, have a look at this article.

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 succeed 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: Environment customization

To learn more about running builds and tests in Buddy, check out this article.

Build Docker image

The next step is dockerizing the application. For this, 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): Build Docker image action configuration

For more info on building Docker images with Buddy, have a look at this article.

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: Run Docker image environment settings

Here you can to read more about running Docker images, volumes, and build arguments.

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.

Since we only release tags in this pipeline, make sure to use the $BUDDY_EXECUTION_TAG variable in the 'Tags' field.

Push Docker Image action configuration

You can read more about Environment Variables and their application in Buddy in here.

See also