# Automatic importing on Git push

ou can make automatic bot deploying on git push.&#x20;

This possible with [Webhooks](https://help.bots.business/libs/webhooks-lib). Make install for this lib.

## Setup

command `/setupGit`

```javascript
var url = Libs.Webhooks.getUrlFor(
   { command: "onGitPush", user_id: user.id }
)

Api.sendMessage({
  text: "Github webhook: " +
     "\n<pre>" + url + "</pre>",
  parse_mode: "html",
  disable_web_page_preview: true
})

Bot.sendMessage(url);
```

execute `/setupGit` copy url and go to Github.com > your repository -> Settings -> Webhooks. Press button "Add webhook"

Past copied url as Payload URL

![](https://3310729168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LVh0yg9olT-QWqi3AYt%2Fuploads%2FollSiY0PfqvJvADg65Kt%2Fimage.png?alt=media\&token=ffbc72cd-de1b-41c1-941a-d3b59e2115da)

Make like this:

![](https://3310729168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LVh0yg9olT-QWqi3AYt%2Fuploads%2FVsZk1KEYtaznzTGmOgQr%2Fimage.png?alt=media\&token=d09e7d8f-ee5d-4e81-bb6a-215bb0d30180)

Go to App - create command `onGitPush`

```javascript
Bot.sendMessage("Start code importing...");

// Bot.exportGit also possible
Bot.importGit({
  branch: "master", // it is master branch
  success: "onGitImportCompleted"
})
```

command `onGitImportCompleted`

just put to answer: "Git import completed"

{% hint style="warning" %}
Commands `onGitPush and onGitImportCompleted`must be in repository also. Because all commands will be deleted on git importing
{% endhint %}

{% hint style="danger" %}
Protect onGitPush command if you need this. Anybody can run it.&#x20;
{% endhint %}
