# GitHub

#### Introduction

You can connect DataJet to your GitHub account. This integration can be used, for example, to:

* Track changes in a script's source code
* Connect development stores with development branches
* Use one codebase across multiple Shopify stores

The integration works both ways. Any change made in the DataJet script editor is automatically pushed to your repository, and any change pushed to the repository is automatically reflected in your DataJet scripts.

#### Prerequisites

Before connecting a GitHub repository with DataJet, you need to have your repository created, ensure that your GitHub user has full permissions to the repository, and install DataJet on your Shopify store.

#### Setup

Following steps are requiored to complete the setup:

1. Create [fine-grained access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) to your Github repository
2. Connect repository via DataJet settings
3. Connect script with a file from repository

**Create fine-grained access token**

This API access token is used to push any changes from DataJet to your repository. To create the token, follow the instructions on the GitHub [website](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token).\
\
Under the ***Repository Access*** section - ensure that your token has access only to the repository you created for DataJet scripts:

<figure><img src="/files/LSD4LvQKMCCG4lpyKUQp" alt=""><figcaption></figcaption></figure>

Under ***Permissions,*** select *Read and write access* for Webhooks and Contents<br>

<figure><img src="/files/ujcwfbA2ImdHkVcbxYWM" alt=""><figcaption></figcaption></figure>

After creating the token, copy it. We will use it in the next step.

**Connect repository via DataJet settings**

Open the DataJet app and go to Settings. At very bottom, select the *Connect GitHub* checkbox and paste your token. Click the Connect button. You should now see repository for which you created the token. Select it and click *Save connection*. If the connection is successful, a green confirmation message will appear at the bottom.

You can now close settings and go to Developer Console to connect your first script.

**Connect script with a file from repository**

Before connecting the script with a file from the repository, ensure that the file is present in your repository. If it isn't, create it before proceeding to the next step.\
\
For the purpose of this tutorial, we will create an `order-created.dj` file inside the `webhooks` directory.<br>

Now we can create a new script in the DataJet Developer Console and connect it to a file created in our repository. After creating the file select cogwheel next to the script name, then choose GitHub. In the modal, select the branch and file.

Connect and close the modal. Your script is now connected to a file in your repository. Any changes to the file will be reflected in the script code, and vice versa.

{% hint style="info" %}
Use refresh button next to repository file name to resync code from the repo file with current script code:\
You can also fully refresh the page to fetch latest script version to the code editor.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datajet-app.com/integrations/github.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
