Multi GIT Remote Deployment via ACLI in Code Studio

  • Last updated
  • 1 minute read

Goal

Push build artifact to multiple remotes using acli "push:artifact" command in Code Studio

Prerequisites

  • Code Studio Build Setup with ACLI

Overview

Acquia CLI is an open source command-line interface for interacting with Acquia Cloud Platform services. One of the command ACLI provide is push:artifact. This commands builds a sanitized deploy artifact and it also simplifies the deployment process by pushing the finalized artifact directly to the Git remotes hosted on the Acquia Cloud Platform.

In this tutorial, we will dive into the procedure for using the push:artifact command within Code Studio to efficiently dispatch the artifact across multiple Git remotes.

 

  1. Multiple Remote Push Using Environment Variable

    • Open the CI/CD settings of the project in Code Studio 
    • Expand the Variables section and add a new variable named ACLI_PUSH_ARTIFACT_DESTINATION_GIT_URLS 
    • In the value of this variable, add comma separated values of the GIT remotes. Example - If two GIT remotes are REMOTE1 and REMOTE2, then the value of this variable will be - REMOTE1,REMOTE2 
    • Save the variable and now run the build and check for push to the configured remotes

       

    CI/CD Settings

     

    Image
    CI/CD variable

     

    Image
    variable value for multiple remotes
  1. Multiple Remote Push Using ACLI Config File

    • Add a file name .acquia-cli.yml in your project root folder
    • In this file, add the git remotes where we want to push the artifact
    • Save the file, commit code and push to repo and verify the deployment to the remotes
    push:
      artifact:
        destination-git-urls:
          - GIT_REMOTE1_HERE
          - GIT_REMOTE2_HERE

     

  1. Multiple Remote Push Using ACLI Command Option

    If you are not using Code Studio but other CI/CD build tool where executing acli push:artifact command yourself, in this case, you can use the ---destination-git-urls command option to provide the multiple GIT remotes.

    ACLI push:artifact command, provides this option and can be used like below -

    acli push:artifact --destination-git-urls=GITREMOTE1HERE --destination-git-urls=GITREMOTE2H

To define and use the git remotes from ACLI config file, make sure that ACLI version is at-least 2.30.0

Additional Resources