> ## Documentation Index
> Fetch the complete documentation index at: https://developers.hubspot.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

---
id: 3d54e2dd-336d-4c3a-a8da-554eb0d758cf
---

# Set up continuous integration with a GitHub repository using GitHub Actions

> Set up continuous integration with a GitHub repository using GitHub Actions.

As a part of your [development workflow](/cms/start-building/introduction/developer-environment/creating-an-efficient-development-workflow), you might prefer to keep your production codebase source of truth in version control. This would be especially helpful if you work as a part of a development team so that you can track changes and quickly roll them back if needed.

Using [GitHub Actions](https://github.com/features/actions), you can set up a continuous integration with a GitHub repository. This guide walks through the integration process, and assumes that you're familiar with:

* [Using Git](https://docs.github.com/en/get-started/using-git) and GitHub
* Building websites using the [HubSpot CLI](/developer-tooling/local-development/hubspot-cli/install-the-cli)

Below, learn how to set up the integration using the HubSpot CMS Deploy GitHub Action (recommended) or manually.

## Send local files to GitHub

Before you can integrate with GitHub, you'll first need to gather your files locally.

* If you have an existing CMS asset that lives in HubSpot, such as a theme or set of templates, you can fetch it by running the [fetch](/developer-tooling/local-development/hubspot-cli/reference#fetch) command as follows: `hs fetch <HubSpot_src> <local_dest>`. Alternatively, you can download all files in the account's [developer file system](/cms/start-building/introduction/overview#developer-file-system) by running `hs fetch /`.
* To create a new local project, it's recommended to start with the [CMS theme boilerplate](/cms/start-building/building-blocks/themes/hubspot-cms-boilerplate). If you haven't worked with the CMS theme boilerplate before, check out the [quickstart guide](/cms/start-building/introduction/classic-hubl-quickstart). If you've already installed the HubSpot CLI and configured your local environment, you can create a new local theme from the boilerplate by running `hs create website-theme <new-theme-name>`. You'll then need to upload your files to HubSpot with the [hs upload](/developer-tooling/local-development/hubspot-cli/reference#upload) command.

With your code available locally, you'll then [add it to a GitHub repository](https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github). After adding your files to GitHub, proceed to the next step to either install HubSpot's pre-made GitHub Action (recommended) or [configure the Action manually](#manually-configure-the-action).

## Use the HubSpot CMS Deploy GitHub Action (recommended)

To streamline the process, HubSpot created a GitHub Action that you can install to your GitHub project to handle automatically deploying changes from a branch to your production HubSpot account.

<CTA id="e0132707-395d-4617-bd9d-0b21c8b129d5" external={true} label="Install automatic CMS deploy GitHub action" />

## Create and merge a pull request in main

* With your secrets, workflows, and scripts in your GitHub repository, create a pull request and merge it into main.
* After merging the pull request, navigate to **Actions**. You should see your deploy Action run, which will then deploy your code to your HubSpot account.

## Lock your asset in the design manager

Now that your source of truth lives in GitHub, you should lock your asset in HubSpot to prevent edits from being made there. This ensures that changes only come through the deploy action.

To lock assets in the design manager:

* In your HubSpot account, navigate to **Marketing** > **Files and Templates** > **Design Tools**.
* Locate your asset's folder in the left sidebar, then **right-click** and select **Lock folder**.

<Frame>
  <img src="https://www.hubspot.com/hubfs/Knowledge_Base_2021/Developer/design-manager-lock-folder.png" alt="design-manager-lock-folder" />
</Frame>
