# Static Sites: Git Deployments

Deploy your static site automatically from a GitHub, GitLab, or Bitbucket repository. Every push to your configured branch triggers a new build and deployment.

## Prerequisites

- A static site with **Git Repository** as the deployment method
- A Git repository hosted on GitHub, GitLab, or Bitbucket

## Supported providers

| Provider | Repository URL format |
|----------|----------------------|
| **GitHub** | `https://github.com/username/repo` |
| **GitLab** | `https://gitlab.com/username/repo` |
| **Bitbucket** | `https://bitbucket.org/username/repo` |

## Repository configuration

When creating or editing a static site with Git deployment, configure:

- **Repository URL** — The HTTPS URL of your repository
- **Branch** — The branch to deploy from (defaults to `main`)
- **Publish directory** — The folder containing your built files (e.g., `dist`, `build`, `public`, or `/` for root)

## Private repositories

For private repositories, select an authentication method:

### SSH key

1. Select **SSH Key** as the authentication type
2. Paste your deploy key (private key)
3. Add the corresponding public key as a deploy key in your repository settings

### Access token

1. Select **Access Token** as the authentication type
2. Enter a personal access token with read access to the repository

**GitHub:** Generate a fine-grained token with `Contents: Read` permission at **Settings > Developer settings > Personal access tokens**.

**GitLab:** Generate a project access token with `read_repository` scope at **Settings > Access Tokens**.

**Bitbucket:** Generate an app password with `Repositories: Read` permission at **Personal settings > App passwords**.

## Setting up webhooks

Webhooks enable automatic deployments when you push to your repository.

### Step 1: Get webhook details

1. Navigate to your site detail page
2. Find the **Git Configuration** section
3. Copy the **Webhook URL** and **Webhook Secret**

### Step 2: Add webhook to your provider

#### GitHub

1. Go to your repository **Settings > Webhooks**
2. Click **Add webhook**
3. **Payload URL** — Paste the webhook URL
4. **Content type** — `application/json`
5. **Secret** — Paste the webhook secret
6. **Events** — Select **Just the push event**
7. Click **Add webhook**

#### GitLab

1. Go to your project **Settings > Webhooks**
2. **URL** — Paste the webhook URL
3. **Secret token** — Paste the webhook secret
4. **Trigger** — Check **Push events**
5. Click **Add webhook**

#### Bitbucket

1. Go to your repository **Settings > Webhooks**
2. Click **Add webhook**
3. **Title** — `DanubeData Deploy`
4. **URL** — Paste the webhook URL
5. **Triggers** — Select **Repository push**
6. Click **Save**

> **Note**: For Bitbucket, the webhook secret is verified via the `X-Hub-Signature` header using HMAC-SHA256.

### Webhook verification

Each provider uses a different signature mechanism:

| Provider | Header | Method |
|----------|--------|--------|
| **GitHub** | `X-Hub-Signature-256` | HMAC-SHA256 |
| **GitLab** | `X-Gitlab-Token` | Token comparison |
| **Bitbucket** | `X-Hub-Signature` | HMAC-SHA256 |

## Auto-deploy

When auto-deploy is enabled, pushes to the configured branch automatically trigger new builds.

### Enabling auto-deploy

1. Navigate to the site detail page
2. Click **Edit**
3. Enable **Auto-deploy on push**
4. Click **Save**

### Branch filtering

Only pushes to the configured branch trigger builds. Pushes to other branches are ignored. To change the deploy branch:

1. Navigate to the site detail page
2. Click **Edit**
3. Update the **Branch** field
4. Click **Save**

## Manual builds from Git

You can trigger a build manually without pushing to the repository:

1. Navigate to the site detail page
2. Click **Redeploy**

This clones the latest commit from the configured branch and starts a new build.

## Build details

Each Git-triggered build records:

- **Commit SHA** — The exact commit that triggered the build
- **Commit message** — The commit message
- **Commit author** — Who made the commit
- **Branch** — The branch that was pushed to
- **Trigger type** — `webhook` for automatic builds, `manual` for manual rebuilds

## Troubleshooting

### Webhook not triggering builds

- Verify the webhook URL and secret match the values shown in the dashboard
- Check that the webhook is configured for push events only
- Ensure **Auto-deploy on push** is enabled in the site settings
- Check the webhook delivery logs in your Git provider for HTTP response codes
- Ensure the push is to the configured branch (other branches are ignored)

### Build fails with "clone failed"

- Verify the repository URL is correct and accessible
- For private repos, check that the SSH key or access token has read permissions
- Ensure the configured branch exists in the repository

### Build succeeds but site shows old content

- Verify the **Publish directory** matches your build output folder
- Check that the built files include an `index.html` at the root of the publish directory
- If your build tool outputs to a different directory, update the publish directory setting

### Webhook shows 401/403 errors

- Regenerate the webhook secret from the site settings
- Update the webhook configuration in your Git provider with the new secret
- Ensure the webhook URL has not been modified

## Next steps

- [Static Sites overview](https://docs.danubedata.ro/static-sites) — Full feature reference
- [Static Sites quick start](https://docs.danubedata.ro/static-sites-quickstart) — Deploy your first site
- [Custom domains](https://docs.danubedata.ro/static-sites-domains) — DNS verification and TLS setup

---

**Questions?** Contact support at support@danubedata.ro
