Deploy from GitLab or GitHub

Deploy review apps on Clever Cloud from GitHub and GitLab

Over the past few months, some customers have raised questions about CI/CD building to deploy from GitHub or GitLab. The two platforms differ significantly on the subject, but are the ones massively used to store code and collaborate.

At Clever Cloud, we’re committed to providing a wide range of products and features to facilitate application deployment and maintenance. We aim to constantly improve our customers’ experience as well. In this article, we detail how we have approached the subject of CI/CD to simplify deployments, regardless of where you store your code.

Two platforms, one common principle

Clever Cloud provides a CLI for deploying and managing both applications and add-ons. So far, we’ve suggested that our customers use it to build their CI/CD. However, writing a pipeline, even with a facilitating tool like a CLI to connect to Clever Cloud, is a long and tedious task. Especially when you’re busy developing your application.

Keeping in mind one of our founding principles, to make the work of developers and IT teams as easy as possible, we started to provide slightly more advanced CI/CD tools, both for GitHub and GitLab.

Deploying from GitHub: go further with review apps

Customers using GitHub are already familiar with our integration, enabling them to deploy from this platform. In addition to this integration, anyone could use the CLI to customize their pipeline.

Based on this configuration, we’ve provided a workflow template for deploying review apps from GitHub to Clever Cloud. This script performs the following actions:

  1. Create and deploy an app on Clever Cloud from the branch where the PR is open, with a test domain name ;
  2. Update the application with each new commit ;
  3. Delete the application when the PR is closed.

A comment posts the link to the review app with each new deployment, and announces the deletion of the app once this job has been completed.

The script retrieves the environment variables and secrets added to your project from GitHub. It’s possible to go further and add commands; for example, to connect the review app to a test database, you could add the command clever service link-addon <addon-name>.

This template is under constant development to progressively simplify your workflow and make it more efficient. Eventually, this Action should work solely with inputs rather than command lines. In the meantime, feel free to open an issue on the project according to your needs.

Deploying from GitLab

Our customers working on GitLab (as a SasS or self-hosted instance) have also expressed similar needs for automating their deployments. GitLab differs significantly from GitHub, with a much more DIY approach to CI/CD and different configurations. On GitLab, there are no variables for detecting the state of a Merge Request (open or closed), unlike GitHub. If we want to launch a job automatically when it closes, we’ ll have to use the state of the environments instead, and not that of the MRs.

At Clever Cloud, we already had different deployment pipelines in place from GitLab for certain projects. We’ve unified and simplified them by creating pipeline components in the GitLab CI/CD catalog. The components replace GitLab’s old template catalog, and enable a modular pipeline to be built using inputs. No need to manually customize a script file anymore.

Our contribution to the catalog currently comprises four components:

  1. Deploy in production;
  2. Creating a review app from a Merge Request;
  3. Update review app;
  4. Delete review app.

The input values have been predefined to save you time when using them. These components can be used both on gitlab.com and on your self-hosted instance. There’s nothing to modify in the project, but a few configurations of your instance to check.

In both cases, we advise you to test the manual triggering of components on your project first. We’ll be adding more components as our customers’ needs change, and are open to your proposals, to be submitted directly on the project dedicated to them.

The best of both worlds: Heptapod

If you use the GitLab Community Edition fork hosted on Clever Cloud, you’ll benefit from the advantages of a GitLab as a Service offering, as well as hosting on European servers managed by a French company.

The CI/CD pipeline catalog is already integrated into our Heptapod offer, enabling you to use the components directly in your project, with no instance configuration required.

A simplified pipeline

Clever Cloud integrates the build, install and run phases of your deployments. All you have to do is push your code, the process is automatic. By including deployment on Clever Cloud in your pipeline, you’ll get logs of your application’s deployment and its various stages directly in the runner’s console. This means:

  • You can skip the build job in your pipeline – our platform already takes care of that.
  • You can monitor your pipeline and its logs directly from GitHub, GitLab or Heptapod, from start to finish.

Remember: if the deployment fails on Clever Cloud, your app will stay up with the last commit you pushed before your update. It won’t crash and your users won’t notice anything. We got you!

As both projects are in constant development, we plan to go even further in adding flexibility and agility to your deployment processes. We remain open to your suggestions!

Blog

À lire également

MateriaDB KV, Functions: discover the future of Clever Cloud at Devoxx Paris 2024

Clever Cloud is proud to present its new range of serverless products: Materia!
Company

Our new logs interface is available in public beta

You can now discover our new log stack interface and its new features!
Company

Deploy from GitLab or GitHub

Over the past few months, some customers have raised questions about CI/CD building to deploy…

Engineering