# Push to Deploy in xCloud: Automatic Deployments From GitHub

> Turn on push to deploy in xCloud so every Git push redeploys your site: generate the private deploy URL, add the webhook, and check each deploy.

Push to deploy redeploys your site every time you push to its Git repository. Your Git provider calls a private **deploy URL** for the site, and xCloud pulls the selected branch and runs your deploy script. You turn it on in the site's **Git** settings.

This guide is for sites that already deploy from Git: Laravel, PHP, Node.js and other Git-based sites, or a WordPress or PHP site with Git added. If your site is not connected to a repository yet, start with [How to Connect GitHub and Deploy Git Projects with xCloud](/docs/how-to-integrate-a-git-provider-with-xcloud/).

## How push to deploy works

- **One private URL per site.** xCloud gives each site its own deploy URL. Anyone who has the URL can start a deploy of that site, so treat it like a password.
- **GitHub can be set up for you.** When you create a site from a repository in your connected GitHub account and you have admin access to it, xCloud can add the webhook to the repository for you: when you add a Git site, turn on **Automatically add webhook to repository** in the site setup wizard. For any other repository you add the webhook yourself.
- **Every push deploys the selected branch.** xCloud does not filter by branch. A push to any branch starts a deploy, and the deploy always pulls the branch set in **Git Branch**.
- **One deploy at a time.** If a deploy is already running when a push arrives, xCloud ignores that push. It is not queued.

## Before you start

- A site that deploys from a Git repository in xCloud.
- To generate the URL you need permission to change the site's deploy settings. Without it, the card says *"Ask a team admin with the deploy-settings permission to regenerate this URL."*
- Access to the repository's webhook settings, unless xCloud added the GitHub webhook for you.

## Step 1: Turn on push to deploy

Open the site and go to **Git** in the site menu. Turn on **Enable push to deploy**, then click **Save Changes**.

![Click the 'Enable push to deploy' switch in Site → Git](/_landing/docs/push-to-deploy-in-xcloud-image-1.png)

**Expected result:** the **Deployment URL** card below the switch shows **Push to deploy: Enabled**.

## Step 2: Generate the deploy URL

In the **Deployment URL** card, click **Generate URL**. If the site already has a URL, the button says **Regenerate URL**.

![Click 'Generate URL' in the Deployment URL card on the site's Git page](/_landing/docs/push-to-deploy-in-xcloud-image-2.png)

xCloud asks you to confirm. The first time, it says the URL is shown only once. If the site already has a URL, it warns that the current URL stops working right away, and that a webhook managed through your connected Git provider is updated automatically. Click **Generate URL** (or **Regenerate URL**) in the dialog.

![Confirm with 'Generate URL' in the 'Generate a deploy URL?' dialog](/_landing/docs/push-to-deploy-in-xcloud-image-3.png)

**Expected result:** xCloud shows *"Your new deploy URL is ready. Show it and copy it now."*

## Step 3: Copy the URL

In the same **Deployment URL** card, click **Show**, then click **Copy** next to the URL. The card warns that the URL will not be shown again. Store it somewhere safe until you have added it to your repository.

The URL is shown only once. If you leave the page without copying it, generate a new one (Step 2).

If xCloud also shows a **Webhook secret**, copy it too. Paste it into the webhook's Secret field. xCloud then only deploys when the call really comes from your repository. The card's **Webhook signature** row says **Required** or **Not required** for your site.

**Expected result:** the URL (and the **Webhook secret**, if shown) is copied, and the card warns it will not be shown again.

## Step 4: Add the webhook to your repository

Skip this step if the card's **Git provider webhook** row shows **Updated automatically**, **Created automatically**, **Confirmed by your Git provider** or **Up to date**, or if the card says *"Your repository webhook now uses the new URL."* Add the webhook yourself only when the row shows **Not managed automatically**, **No webhook found in the repository** or another value.

To add the webhook yourself, open your repository's webhook settings and add a new webhook:

1. **URL:** paste the deploy URL.
2. **Events:** choose push events only.
3. **Secret:** paste the webhook secret, if xCloud showed one.
4. Save the webhook.

On GitHub this is **Settings → Webhooks → Add webhook** (Payload URL, content type `application/json`, "Just the push event"). See GitHub's guide to [creating webhooks](https://docs.github.com/en/webhooks/using-webhooks/creating-webhooks). GitLab and Bitbucket work if the card shows **Webhook signature: Not required**. Add the deploy URL as a push webhook and leave the secret empty. If it shows **Required**, GitLab and Bitbucket pushes are refused, so contact support.

**Expected result:** GitHub sends a test request when you save the webhook. xCloud answers it without starting a deploy.

## Step 5: Push and check the deploy

Push a commit to your repository. Then open **Deployments** in the site menu.

![A deploy started by a push shows 'Push to deploy' in Site → Deployments](/_landing/docs/push-to-deploy-in-xcloud-image-4.png)

**Expected result:** a new deployment appears with **Push to deploy** where a manual deploy shows the person who started it. Click it to read the build steps and the full log. The card on the **Git** page also updates **Last used**.

For more on the history list and logs, see [View Git Deployments in xCloud](/docs/view-git-deployments-in-xcloud/).

## Pause or turn off push to deploy

Turn off **Enable push to deploy** and click **Save Changes**. The webhook can stay in place: xCloud receives the pushes but does not deploy. Turn the switch back on to resume. You can still deploy by hand with **Save and deploy** on the Git page, or **Deploy Now** at the top of the site page (paid plans).

## Replace a leaked or lost URL

Click **Regenerate URL** in the **Deployment URL** card and confirm. The old URL stops working right away. Copy the new URL and update the webhook in your repository, plus any build tool or script that still uses the old URL. Until you do, pushes will not deploy.

## When a push does not deploy

| What you see | What it means | What to do |
| --- | --- | --- |
| No new row in **Deployments** after a push | Push to deploy is off, or a deploy was already running | Check **Enable push to deploy**; wait for the running deploy, then push again |
| Your Git provider's webhook page shows a **403** error | The webhook secret does not match | Regenerate the URL and enter the new secret with the new URL |
| Your Git provider's webhook page shows a **404** or **410** error | The URL is wrong or was replaced | Regenerate the URL and update the webhook |
| Your Git provider's webhook page shows a **409** error | The site is disabled or still being migrated | Enable the site, or wait until migration finishes, then push again |
| Your Git provider's webhook page shows a **429** error | More than 30 pushes arrived in one minute | Wait a minute, then push again |
| The deploy ran the wrong code | Deploys always pull the selected branch | Check **Git Branch** in the site's Git settings |

For deploys that start but fail or get stuck, see [Troubleshooting Git Deployments](/docs/troubleshooting-git-deployments-stuck-failed-or-not-triggering/). To go back to a working release, see [Roll Back a Deployment in xCloud](/docs/roll-back-a-deployment-in-xcloud/).

## Frequently asked questions

### Does a push to any branch start a deploy?

Yes. xCloud does not filter by branch. A push to any branch of the repository starts a deploy, and that deploy always pulls the branch selected in the site's Git settings.

### What happens if I push while a deploy is still running?

xCloud ignores that push. It does not queue it. Push again after the running deploy finishes.

### Can I use push to deploy with GitLab or Bitbucket?

Yes, if the card shows **Webhook signature: Not required**. Add the deploy URL as a push webhook and leave the secret empty. If it shows **Required**, GitLab and Bitbucket pushes are refused, so contact support.

### I lost my deploy URL. How do I get it back?

xCloud shows the URL only once. Click Regenerate URL in the site's Git settings to get a new one, then update the webhook. The old URL stops working right away.

If you run into any issues with push to deploy, feel free to reach out to our [support team](/docs/access-built-in-support-portal-in-xcloud/).
