PHPackages                             senangprint/git-deploy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. senangprint/git-deploy

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

senangprint/git-deploy
======================

A PHP script to automatically pull from a repository to a web server (using a webhook on GitHub, GitLab, or Bitbucket).

231PHP

Since Sep 27Pushed 2y agoCompare

[ Source](https://github.com/senangprint/git-deploy)[ Packagist](https://packagist.org/packages/senangprint/git-deploy)[ RSS](/packages/senangprint-git-deploy/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

git-deploy
==========

[](#git-deploy)

A PHP script to automatically pull from a repository to a web server (using a webhook on GitHub, GitLab, or Bitbucket).

You can configure which branch this script pulls from. This script is useful for both development and production servers.

---

On your server
--------------

[](#on-your-server)

### SSH

[](#ssh)

Generate an SSH key and add it to your account so that `git pull` can be run without a password.

- [GitHub documentation](https://help.github.com/articles/generating-ssh-keys/)
- [GitLab documentation](http://doc.gitlab.com/ce/ssh/README.html)
- [Bitbucket documentation](https://confluence.atlassian.com/bitbucket/add-an-ssh-key-to-an-account-302811853.html)

### Configuration

[](#configuration)

Copy the **git-deploy** folder and its contents in to your public folder (typically public\_html). Note that you can change the name of the folder if desired.

Rename **git-deploy/deploy.sample.php** to **git-deploy/deploy.php**, and update each variable to a value that suits your needs. Multiple copies of **git-deploy/deploy.sample.php** can be made for multiple projects or versions (you just need to change the webhook url to match the new name). An example of a live configuration is below.

```
define("TOKEN", "secret-token");
define("REMOTE_REPOSITORY", "git@github.com:username/custom-project.git");
define("DIR", "/var/www/vhosts/repositories/custom-project");
define("BRANCH", "refs/heads/master");
define("LOGFILE", "deploy.log");
define("GIT", "/usr/bin/git");
define("MAX_EXECUTION_TIME", 180);
define("BEFORE_PULL", "/usr/bin/git reset --hard @{u}");
define("AFTER_PULL", "/usr/bin/node ./node_modules/gulp/bin/gulp.js default");
```

### Permissions

[](#permissions)

When **deploy.php** is called by the web-hook, the webserver user (`www`, `www-data`, `apache`, etc...) will attempt to run `git pull ...`. Since you probably cloned into the repository as yourself, and your user therefore owns it, the webserver user needs to be given write access. It is suggested this be accomplished by changing the repository group to the webserver user's and giving the group write permissions:

1. Open a terminal to the directory containing the repository on the server.
2. run `sudo chown -R yourusername:webserverusername custom-project-repo-dir/` to change the group of the repo.
3. run `sudo chmod -R g+s custom-project-repo-dir/` to make the group assignment inherited for new files/dirs.
4. run `sudo chmod -R 775 custom-project-repo-dir/` to set read &amp; write for both owner and group.

---

On GitHub | GitLab | Bitbucket
------------------------------

[](#on-github--gitlab--bitbucket)

### GitHub

[](#github)

In your repository, navigate to Settings → Webhooks → Add webhook, and use the following settings:

- Payload URL:
- Content type: application/json
- Secret: The value of TOKEN in config.php
- Which events would you like to trigger this webhook?: 🔘 Just the push event
- Active: ☑️

Click "Add webhook" to save your settings, and the script should start working.

[![Example screenshot showing GitHub webhook settings](https://cloud.githubusercontent.com/assets/1123997/25409764/f05526d0-29d8-11e7-858d-f28de59bd300.png)](https://cloud.githubusercontent.com/assets/1123997/25409764/f05526d0-29d8-11e7-858d-f28de59bd300.png)

### GitLab

[](#gitlab)

In your repository, navigate to Settings → Integrations, and use the following settings:

- URL:
- Secret Token: The value of TOKEN in config.php
- Trigger: ☑️ Push events
- Enable SSL verification: ☑️ (only if using SSL, see [GitLab's documentation](https://gitlab.com/help/user/project/integrations/webhooks#ssl-verification) for more details)

Click "Add webhook" to save your settings, and the script should start working.

[![Example screenshot showing GitLab webhook settings](https://cloud.githubusercontent.com/assets/1123997/25409763/f0540a16-29d8-11e7-95d1-5570c574fde0.png)](https://cloud.githubusercontent.com/assets/1123997/25409763/f0540a16-29d8-11e7-95d1-5570c574fde0.png)

### Bitbucket

[](#bitbucket)

In your repository, navigate to Settings → Webhooks → Add webhook, and use the following settings:

- Title: git-deploy
- URL:
- Active: ☑️
- SSL / TLS: ⬜ Skip certificate verification (only if using SSL, see [Bitbucket's documentation](https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html#ManageWebhooks-skip_certificate) for more details)
- Triggers: 🔘 Repository push

Click "Save" to save your settings, and the script should start working.

[![Example screenshot showing Bitbucket webhook settings](https://cloud.githubusercontent.com/assets/1123997/25353602/7aee9cde-28f5-11e7-9baa-eb1e1330017e.png)](https://cloud.githubusercontent.com/assets/1123997/25353602/7aee9cde-28f5-11e7-9baa-eb1e1330017e.png)

Integration with CI/CD
----------------------

[](#integration-with-cicd)

If you'd prefer to integrate git-deploy with your CI scripts rather than using traditional Webhooks, you can trigger the hook via the following `wget` command.

```
wget --quiet --output-document=- --content-on-error --header="Content-Type: application/json" --post-data='{"ref":"refs/heads/master"}' 'https://www.example.com/git-deploy/deploy.php?token=secret-token'
```

Additionally, you can add the parameters `sha=COMMIT_HASH` and `reset=true` to the URL in order to instruct git-deploy to reset to a specific commit. **Note that this will overwrite any local changes you may have made.** This can be useful for integration with things like [GitLab's Environments feature](https://gitlab.com/help/ci/environments).

---

I appreciate the collaboration of @JacobDB

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 52.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/15feb9af124f32090b2bdf19293fe9c514074695bc82c249c1f1bd4cb7082e7d?d=identicon)[jvloo](/maintainers/jvloo)

---

Top Contributors

[![JacobDB](https://avatars.githubusercontent.com/u/1123997?v=4)](https://github.com/JacobDB "JacobDB (37 commits)")[![vicenteguerra](https://avatars.githubusercontent.com/u/7199402?v=4)](https://github.com/vicenteguerra "vicenteguerra (18 commits)")[![xavierloo](https://avatars.githubusercontent.com/u/5669718?v=4)](https://github.com/xavierloo "xavierloo (9 commits)")[![evansharp](https://avatars.githubusercontent.com/u/1461350?v=4)](https://github.com/evansharp "evansharp (2 commits)")[![hucruz](https://avatars.githubusercontent.com/u/13157707?v=4)](https://github.com/hucruz "hucruz (2 commits)")[![aaronalbers](https://avatars.githubusercontent.com/u/37545192?v=4)](https://github.com/aaronalbers "aaronalbers (1 commits)")[![paimpozhil](https://avatars.githubusercontent.com/u/304180?v=4)](https://github.com/paimpozhil "paimpozhil (1 commits)")

### Embed Badge

![Health badge](/badges/senangprint-git-deploy/health.svg)

```
[![Health](https://phpackages.com/badges/senangprint-git-deploy/health.svg)](https://phpackages.com/packages/senangprint-git-deploy)
```

###  Alternatives

[deployer/deployer

Deployment Tool

11.1k25.4M207](/packages/deployer-deployer)[appwrite/server-ce

End to end backend server for frontend and mobile apps.

55.3k84.2k](/packages/appwrite-server-ce)[pragmarx/health

Laravel Server &amp; App Health Monitor and Notifier

2.0k1.0M2](/packages/pragmarx-health)[felixfbecker/language-server-protocol

PHP classes for the Language Server Protocol

22476.7M6](/packages/felixfbecker-language-server-protocol)[heroku/heroku-buildpack-php

Toolkit for starting a PHP application locally, with or without foreman, using the same config for PHP and Apache2/Nginx as on Heroku

8161.3M10](/packages/heroku-heroku-buildpack-php)[tiamo/phpas2

PHPAS2 is a php-based implementation of the EDIINT AS2 standard

4674.7k](/packages/tiamo-phpas2)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
