Code Studio: Repository Mirroring

  • Last updated
  • 1 minute read

Goal

Share Code from a Code Studio project out to another Git repository

Prerequisites

  • A Code Studio Repository
  • Another Git Repository (e.g. Github, Bitbucket, etc.)
  • Administrative Access to Both Repositories

Overview

Many organizations have existing git hosting in place. Acquia wants to support your organization's security and storage needs and Code Studio offers repository mirroring to offer the best of both worlds. Get all the benefits of Code Studio AND store the resulting code in your organization's existing git repo. 

In this day and age, it's (thankfully) rare to find organizations that haven't adopted git for their version control needs. In fact, one of the most common conversations I have when we start talking to folks about Acquia Code Studio usually goes something like this... "Well, our organization is already setup to use <insert your git provider of choice. Can we still use Code Studio?" The short answer is yes! But, as with most things there's a much longer answer, and this article is going to dive into one of my favorite Gitlab features (which gets us to that yes): Repository Mirroring. 

What is Repository Mirroring

Repository Mirroring is a concept that slips into any existing git / development / devops workflow you might already have in place. Essentially, this process takes whatever you do in your repository and "mirrors" it into one (or more) other repositories. Here's a quick, real world example:

Let's imagine a team of developers working in Code Studio. A developer on that team opens a merge request (MR), which in turn kicks off the CI/CD workflow in pipelines. Once the build has passed and the tech lead has reviewed the work, the MR is merged and the commits ultimately end up in the repository's develop branch.

Pretty basic (and hopefully familiar), right? Now, let's imagine that this Code Studio repository has a mirrored twin living out in the organization's Github. When the MR gets merged into the Code Studio develop branch, the Repository Mirroring feature will "mirror" that commit from the Code Studio repo out into the Github repo. 

The end result is that the organization's Github repository stays in sync with the Code Studio repository but the development team only has to work in one location. 

Why Should You Use Repository Mirroring?

One of the biggest advantages of using Code Studio over other CI/CD tools is that Acquia maintains the build scripts and secure connection into Acquia hosting. However, to take advantage of these (and other) features in Code Studio, your code needs to live in a Code Studio git repository. For some organizations, this is no barrier to entry! For some of our customers though, they have existing repositories being hosted elsewhere that they cannot easily move (due to their own internal policies). Repository Mirroring is a great solution for this as it lets you have the best of both worlds. On the one hand, you get all the benefits of Code Studio (as your team will be working in Code Studio). On the other hand, you will still have all your code stored in your organization's git repository outside of Code Studio (kept up to date by the mirroring feature). 

How to Configure Repository Mirroring 

Repository Mirroring is a very simple feature to setup in Code Studio, but you do need to have elevated access to both repositories to successfully implement this feature. 

First, you'll want to visit the repo in Code Studio that you want to mirror. You will need to be an administrator in this repo! Click on Settings in your left sidebar and then select Repository.

From this page, you’ll want to find and expand the Repository Mirroring section.

Setting up the mirroring process requires a few pieces of information:

  • The URL of the Git repository
  • The username of the account that will push
  • A token for that user (instead of your password)

The token must be configured on the Github side to allow for pushing to the repository. 

Once the config is in place, you will no longer need to touch the mirrored repository. All of your actions taken in Code Studio will automatically be pushed out to the mirrored repository.