Sign InTry Free

Deploy Data App Automatically with GitHub

TiDB Cloud provides a Configuration as Code (CaC) approach to represent your entire Data App configurations as code using the JSON syntax.

By connecting your Data App to GitHub, TiDB Cloud can use the CaC approach and push your Data App configurations as configuration files to your preferred GitHub repository and branch.

If Auto Sync & Deployment is enabled for your GitHub connection, you can also modify your Data App by updating its configuration files on GitHub. After you push the configuration file changes to GitHub, the new configurations will be deployed in TiDB Cloud automatically.

This document introduces how to deploy your Data App automatically with GitHub and how to manage the GitHub connection.

Before you begin

Before you connect a Data App to GitHub, make sure that you have the following:

  • A GitHub account.
  • A GitHub repository with your target branch.

Step 1. Connect your Data App to GitHub

You can connect your Data App to GitHub when you create the App. For more information, see Create a Data App.

If you did not enable the GitHub connection during the App creation, you can still enable it as follows:

  1. Navigate to the Data Service page of your project.

  2. In the left pane, click the name of your target Data App to view its details.

  3. On the Settings tab, click Connect in the Connect to GitHub area. A dialog box for connection settings is displayed.

  4. In the dialog box, perform the following steps:

    1. Click Install on GitHub, and then follow the on-screen instructions to install TiDB Cloud Data Service as an application on your target repository.

    2. Click Authorize to authorize access to the application on GitHub.

    3. Specify the target repository, branch, and directory where you want to store the configuration files of your Data App.

    4. To allow Data App changes made in either TiDB Cloud console or GitHub are synchronized with each other, enable Configure Auto Sync & Deployment.

      • When it is enabled, the changes made in your specified GitHub directory can be automatically deployed in TiDB Cloud, and the changes made in the TiDB Cloud console can be pushed to GitHub as well. You can find the corresponding deployment and commit information in the Data App deployment history.
      • When it is disabled, the changes made in your specified GitHub directory will NOT be deployed in TiDB Cloud, and the changes made in the TiDB Cloud console will NOT be pushed to GitHub either.
  5. Click Confirm Connect.

Step 2. Synchronize Data App configurations with GitHub

If GitHub connection is enabled when you create a Data App, TiDB Cloud pushes the configuration files of this Data App to GitHub immediately after the App creation.

If GitHub connection is enabled after the App creation, you need to perform a deployment operation to synchronize the Data App configurations with GitHub. For example, you can click the Deployments tab, and then re-deploy a deployment for this Data App.

After the deployment operation, check your specified GitHub directory. You will find that the Data App configuration files have been committed to the directory by tidb-cloud-data-service, which means that your Data App is connected to GitHub successfully. The directory structure is as follows:

├── │ ├── data_sources │ │ └── cluster.json # specifies the linked clusters. │ ├── dataapp_config.json # specifies the Data APP ID, name, type, version, and description. │ ├── http_endpoints │ │ ├── config.json # specifies the endpoints. │ │ └── sql # contains SQL files of the endpoints. │ │ ├── -.sql │ │ ├── -.sql │ │ └── -.sql

Step 3. Modify your Data App

When Auto Sync & Deployment is enabled, you can modify your Data App using either GitHub or the TiDB Cloud console.

Option 1: Modify your Data App by updating files on GitHub

When updating the configuration files, pay attention to the following:

File directoryNotes
data_source/cluster.jsonWhen updating this file, make sure that you have access to the linked clusters. You can get the cluster ID from the cluster URL. For example, if the cluster URL is https://tidbcloud.com/console/clusters/1234567891234567890/overview, the cluster ID is 1234567891234567890.
http_endpoints/config.jsonWhen modifying the endpoints, make sure that you follow the rules described in HTTP endpoint configuration.
http_endpoints/sql/method-<endpoint-path>.sqlTo add or remove SQL files in the http_endpoints/sql directory, you need to update the corresponding endpoint configurations as well.
datapp_config.jsonDo not change the app_id field in this file unless your dataapp_config.json file is copied from another Data App and you want to update it to the ID of your current Data App. Otherwise, the deployment triggered by this modification will fail.

For more information about the field configuration in these files, see Data App configuration files.

After the file changes are committed and pushed, TiDB Cloud will automatically deploy the Data App with the latest changes on GitHub. You can view the deployment status and commit information in the deployment history.

Option 2: Modify your Data App in the TiDB Cloud console

After modifying your Data App endpoints in the TiDB Cloud console (such as modifying endpoints), you can review and deploy the changes to GitHub as follows:

  1. Click Deploy in the upper-right corner. A dialog is displayed for you to review the changes you made.

  2. Depending on your review, do one of the following:

    • If you still want to make further changes based on the current draft, close this dialog and make the changes.
    • If you want to revert the current changes to the last deployment, click Discard Draft.
    • If the current changes look fine, write a change description (optional), and then click Deploy and Push to GitHub. The deployment status will be displayed in the top banner.

If the deployment is successful, the changes made in the TiDB Cloud console will be pushed to GitHub automatically.

Import configurations of an existing Data App

To import configurations of an existing Data App to a new Data App, take the following steps:

  1. Copy configuration files of the existing Data App to a new branch or directory on GitHub.

  2. On the Data Service page of your project, create a new Data App without connecting to GitHub.

  3. Connect your new Data App to GitHub with Auto Sync & Deployment enabled. When you specify the target repository, branch, and directory for your new Data App, use your new path with the copied configuration files.

  4. Get the ID and name of your new Data App. You can click the name of your new Data App in the left pane and get the App ID and name in the Data App Properties area of the right pane.

  5. In your new path on GitHub, update the app_id and app_name in the datapp_config.json file to the ID and name you get, and then push the changes.

    After the file changes are pushed to GitHub, TiDB Cloud will automatically deploy your new Data App with the latest changes.

  6. To view the imported configurations from GitHub, refresh the webpage of the TiDB Cloud console.

    You can also view the deployment status and commit information in the deployment history.

Edit GitHub connection

If you want to edit the GitHub connection for your Data App (such as switching the repository, branch, and directory), perform the following steps.

  1. Navigate to the Data Service page of your project.

  2. In the left pane, click the name of your target Data App to view its details.

  3. In the Connect to GitHub area, click . A dialog box for connection settings is displayed.

  4. In the dialog box, modify the repository, branch, and directory of your Data App.

  5. To allow Data App changes made in either TiDB Cloud console or GitHub are synchronized with each other, enable Configure Auto Sync & Deployment.

    • When it is enabled, the changes made in your specified GitHub directory can be automatically deployed in TiDB Cloud, and the changes made in the TiDB Cloud console can be pushed to GitHub as well. You can find the corresponding deployment and commit information in the Data App deployment history.
    • When it is disabled, the changes made in your specified GitHub directory will NOT be deployed in TiDB Cloud, and the changes made in the TiDB Cloud console will NOT be pushed to GitHub either.
  6. Click Confirm Connect.

Remove GitHub connection

If you no longer want to connect your Data App to GitHub, take the following steps:

  1. Navigate to the Data Service page of your project.
  2. In the left pane, click the name of your target Data App to view its details.
  3. On the Settings tab, click Disconnect in the Connect to GitHub area.
  4. Click Disconnect to confirm the disconnection.

After the disconnection operation, your Data App configuration files will remain in your GitHub directory but will not be synchronized by tidb-cloud-data-service anymore.

Was this page helpful?

Download PDFRequest docs changesAsk questions on Discord
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
© 2024 PingCAP. All Rights Reserved.
Privacy Policy.