Skip to content

Connect GitHub, GitLab, or Bitbucket

Make a GitHub, GitLab, Bitbucket, or other Git repository the source of code for staging and every preview of a site, with a read only deploy key and a webhook.

You can keep your code on GitHub, GitLab, Bitbucket, or any Git host and let WP Waterfall pull it into staging and into your previews. One repository serves the whole site: staging follows the branch you name, and each preview environment follows the branch with the same name in Git. WP Waterfall uses a deploy key, so it never needs your GitHub password or access to your other repositories.

Before you start

  • Open Environments in the site sidebar and find the External repository card. The card is off until you click Enable at its top right. Clicking it opens the form and changes nothing yet: WP Waterfall connects the repository only when you click Connect repository. A member who cannot deploy code sees the button but cannot use it.
  • Staging and every preview must be in Git mode, the default. If one is in SFTP mode, switch it back on the Code card of its Info page. See Git access.
  • Live never connects. Code reaches live only by a promote from staging.

1. Add the deploy key

On the External repository card, click Show deploy key and copy it. WP Waterfall makes one key for the site and keeps the private half to itself. If the key leaks or a team member leaves, a new key (the API with rotate: true, or the MCP tool rotate_deploy_key) replaces it: the old key stops working at once, so add the new one on the Git host and remove the old one there.

GitHub: open the repository, then Settings, Deploy keys, Add deploy key. Name it WP Waterfall, paste the key, leave Allow write access off, and click Add key.

GitLab: Settings, Repository, Deploy keys. Paste the key and leave write access off.

Bitbucket: Repository settings, Access keys, Add key.

2. Connect the repository

Enter the SSH address of the repository, such as git@github.com:acme/site.git, and the Staging branch: the branch that staging follows, such as main or master. Type the name yourself. WP Waterfall does not guess it. Every field is required, and Connect repository stays off until each field is valid. Changed your mind? Click Disable before you connect, and nothing is saved.

WP Waterfall shows a webhook URL and a secret. Copy the secret now: WP Waterfall shows it only once.

For GitHub, GitLab, and Bitbucket, WP Waterfall already knows the host's SSH key. For another host, the card asks for a required Host key: paste the host's known_hosts line (run ssh-keyscan your.git.host to get it). Through the API you can send "host_key_policy": "accept_first" instead, and WP Waterfall records the key it sees on the first pull and refuses any other key after that.

3. Add the webhook

GitHub: Settings, Webhooks, Add webhook. Payload URL: the webhook URL. Content type: application/json. Secret: the secret. Events: Just the push event.

GitLab: Settings, Webhooks. URL: the webhook URL. Secret token: the secret. Trigger: Push events.

Bitbucket: Repository settings, Webhooks, Add webhook. URL: the webhook URL. Secret: the secret. Trigger: Repository push.

One webhook serves staging and all previews.

How environments follow branches

Environment Follows this branch in Git
Staging The Staging branch you typed
A preview named feature-a The branch feature-a
A preview you pointed elsewhere The branch you chose in the Remote branch column

The table on the card shows each environment, the branch it follows, and its status. To follow a branch with a different name, edit the Remote branch cell of a preview environment. The preview is then replaced with that remote branch's code. No two environments can follow the same remote branch.

A preview you make in WP Waterfall starts from staging's code. It then follows its remote branch as soon as that branch exists. Until then the card says Waiting for remote branch feature-a. That is not an error: push the branch and it updates.

4. Pull

WP Waterfall pulls once right after you connect, to check the key works. After that, every push to a branch pulls into the environment that follows it. Click Pull now on a row at any time.

Each pull is a job you can follow under Jobs. WP Waterfall builds the new commit and switches the environment to it.

New branches you push

When you push a branch that no environment follows, the card lists it under Unlinked remote branches with the time it was last seen. For each one you can click Create preview (WP Waterfall makes a preview with that name and pulls the remote branch into it; when all 5 included previews and every environment you bought are in use, the button opens the purchase first, as Create environment does) or Ignore.

To have WP Waterfall do this for you, turn on Create a preview environment when a new remote branch is pushed. It is off until you turn it on. It uses only the previews every site includes. It never uses an additional preview slot, and when no included place is free the branch stays in the list. A name that cannot be an environment name, such as feature/login, stays in the list: make a preview with a name you choose and set its remote branch.

Deleting a branch in Git never deletes an environment.

When a pull fails

The card says What to do
The Git host refused WP Waterfall's deploy key Add the deploy key to the repository (step 1), then click Pull now
Not a fast forward The branch on your Git host does not contain the commit the environment runs. This happens on the first connect of a repository with its own history. Click Replace with the remote branch. WP Waterfall keeps the old commit
The host key changed Your Git host shows a different SSH key than before. If the host really changed it, connect again
Could not find the repository Check the address
Could not find the branch Check the staging branch name on staging. A preview environment waits instead

Before you connect

When you click Connect repository, WP Waterfall asks first and lists what changes. Staging and your preview environments then take their code only from the repository.

What turns off

  • SFTP, and the switch to SFTP mode.
  • Git pushes to WP Waterfall, and file changes to code on the Files page.
  • Automatic updates for plugins and themes, in Git mode and in SFTP mode, because WP Waterfall would commit the updates and the code must arrive only from your repository.
  • Safe Updates, and the deploy to live option of automatic updates.

What stays: live and promotes, the uploads folder, backups, the database tools, domains, and WP-CLI.

How to get it back: disconnect the repository. SFTP and Git through WP Waterfall come back at once. Automatic updates and Safe Updates do not turn themselves back on. You turn them on again if you want them. Connecting also switches off the automatic update switches, Safe Updates, and deploy to live on every environment that had them on, and writes that to User activity.

While connected

  • SFTP and Git through WP Waterfall are off for staging and every preview, so there is one source of truth. Pushes to the WP Waterfall remote are refused, Clone with Git and the SFTP | Git switch are gone, and the SFTP and SSH users card on Info is replaced by a line that links back to Environments. Push to your Git host instead. A preview you make while connected starts in Git mode.
  • Automatic updates are off. On Plugins and Themes every automatic update switch is off and grayed, with the line "Updates come from your Git repository." Safe Updates show the same line. Change plugins and themes in the repository.
  • The Files page takes changes in the uploads and cache folders only. A change to code answers "Change them in the repository."
  • Your account SSH keys are not sent to the environments.
  • In the API, the routes that would turn these on answer 409 with the code external_repository_connected and a plain sentence, before any job exists. That covers Git over SSH, Git tokens, SFTP users, SSH keys on an environment, the switch to SFTP mode, automatic updates, Safe Updates, and file changes to code. A job that was queued earlier ends with the same sentence before it reaches the server.
  • WP Waterfall does not commit anything back to your repository. Code only arrives from there, so there is nothing to commit from an environment.
  • Rotate secret makes a new secret and stops the old one at once. Update the webhook on your Git host.
  • To disconnect, click Disable, then Disconnect. The pulls stop, the code stays as it is on every environment, and Git and SFTP through WP Waterfall come back on. Automatic updates and Safe Updates stay off until you turn them on again.

Deploy from CI instead

WP Waterfall runs your build steps from wpwaterfall.yml, so you do not need to build in CI. To deploy from GitHub Actions, push from the workflow with a Git token, or keep this connection and let the workflow wait for the build and promote. See Deploy from GitHub Actions.

API

  • POST /v1/sites/{id}/git/deploy-key
  • PUT /v1/sites/{id}/git/connection with {"remote_url": "git@github.com:acme/site.git", "staging_branch": "main", "confirm": true}; GET reads the connection, the environments, and the unlinked branches; PATCH with {"auto_create_branches": true} turns on automatic branches; DELETE ?confirm=true disconnects
  • PUT /v1/environments/{id}/git/remote-branch with {"remote_branch": "release-1", "confirm": true} (null goes back to the name)
  • POST /v1/environments/{id}/git/pull, with {"replace": true, "confirm": true} to replace the branch
  • POST /v1/sites/{id}/git/webhook-secret, POST /v1/sites/{id}/git/unlinked-branches/create, and POST /v1/sites/{id}/git/unlinked-branches/ignore
  • Webhook receiver: POST /hooks/git/{connection_id} (GitHub and Bitbucket sign with HMAC SHA-256, GitLab sends the secret as a token)
  • MCP tools: get_git_repository, connect_git_repository, disconnect_git_repository, pull_git_repository, set_remote_branch, set_auto_create_branches, create_branch_from_remote, and ignore_remote_branch

Still stuck?

Email support at wpwaterfall dot com with your site name and what you tried, or send us a message.