{"id":17031200,"url":"https://github.com/pskopnik/Git-Deployment-Handler","last_synced_at":"2026-04-15T08:30:17.446Z","repository":{"id":2957013,"uuid":"3971207","full_name":"pskopnik/Git-Deployment-Handler","owner":"pskopnik","description":"Tool to automatically deploy git commits using post-receive hooks and cron jobs","archived":false,"fork":false,"pushed_at":"2023-05-14T11:46:20.000Z","size":119,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-14T08:10:53.017Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pskopnik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2012-04-09T11:41:31.000Z","updated_at":"2023-05-14T11:29:02.000Z","dependencies_parsed_at":"2023-07-06T09:01:49.509Z","dependency_job_id":null,"html_url":"https://github.com/pskopnik/Git-Deployment-Handler","commit_stats":null,"previous_names":["seoester/git-deployment-handler"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pskopnik%2FGit-Deployment-Handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pskopnik%2FGit-Deployment-Handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pskopnik%2FGit-Deployment-Handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pskopnik%2FGit-Deployment-Handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pskopnik","download_url":"https://codeload.github.com/pskopnik/Git-Deployment-Handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219847664,"owners_count":16556349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T08:10:57.154Z","updated_at":"2026-04-15T08:30:17.402Z","avatar_url":"https://github.com/pskopnik.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Git Deployment Handler\n=======================\n\nThe Git Deployment Handler is a tool for automatic deployment of git commits from local or remote repositories into (local) directories.\n\nSome advanced features require a database; SQlite, MongoDb and MySQL are the supported database backends.\nThe Git Deployment Handler uses post-receive hooks and cron jobs (services in future) to automatically deploy commits.\n\n## Requirements\n\n * python3\n * git (command line tool)\n * __For some features either__\n\t* _sqlite3_\n\t* mysql and PyMySQL\n\t* mongodb and pymongo\n\n## Installation\n\nThe easiest way to install [gitdh](https://pypi.python.org/pypi/gitdh/) is to use the [Python Package Index](https://pypi.python.org/pypi):\n\n\t# # It is necessary to use python3, so instead of pip, pip3 or pip-3.2, ... might have to be used\n\t# pip install gitdh\n\nOr manually install from source:\n\n\t# python3 setup.py install\n\n## Getting Started\n\nIn this example the `master` branch of a local repository (hosted using gitolite) is deployed to a webserver directory using a post-receive hook.\n\ngitdh requires a configuration using INI syntax file for every repository whose branches are to be deployed.\nThe path to the repository has to be in the `RepositoryPath` option of the `Git` section.\nThe branch to be deployed must have its own section in the configuration file with a `Path` option being the directory the branch is to be deployed to.\n\nSo to deploy the `/var/lib/gitolite/repositories/website.git` repository to `/home/www/website`, the following is put into `/var/lib/gitolite/gitdh-website.conf`:\n\n\t[Git]\n\tRepositoryPath = /var/lib/gitolite/repositories/website.git\n\n\t[master]\n\tPath = /home/www/website\n\nThe post-receive hooks is installed using the following command, it is also necessary to give the `gitolite` user write access to the deployment directory.\n\n\t# mkdir -p /home/www/website\n\t# chown gitolite:www-data /home/www/website\n\t# chmod g+rx /home/www/website\n\t# git-dh install postreceive /var/lib/gitolite/gitdh-website.conf\n\nFrom now on gitdh will deploy all new commits pushed to the `website` repository to the `/home/www/website` directory.\n\nAlso check the `docs/` ([Github](https://github.com/seoester/Git-Deployment-Handler/tree/master/docs)) directory for sample configuration files.\n\n## Configuration\n\ngitdh is configured using a config file in INI syntax.\n\nIt can either be stored somewhere on the file system or in a file named `gitdh.conf` in a `gitdh` branch of a git repository.\nThis file or such a git repository is referred to as **target** within gitdh.\nSome sample config files can be found in the `docs/` directory.\n\nThe `Git` section of the file contains all file-wide settings; The most important one is the `RepositoryPath` of the git repository to be deployed.\nThis setting can be omitted when the config file is placed in a git repository (named `gitdh.conf` in a `gitdh` branch).\n\n\t[Git]\n\tRepositoryPath = /var/lib/gitolite/repositories/webapp.git\n\nAdditional Options:\n\n * `External` - `True` or `False`, whether the Source is an external (i.e. remote) repository; (requires a database); default `False`\n * `IdentityFile` - May contain the path of an IdentityFile (as in .ssh/config) when External is used and Source is a SSH URL; default `None`\n\n### Branches\n\nFor every branch which should be deployed, a section named like the branch has to be created. The `Path` setting specifies the path to be deployed to:\n\n\t[master]\n\tPath = /srv/www/webapp.com/\n\nAdditional Options:\n\n * `RmGitIntFiles` - `True` or `False`, whether internal git files should be deleted (`.git/`, `.gitignore`, `.gitmodules`); default `True`\n * `Recursive` - `True` or `False`, whether a clone should be `recursive`, i.e. submodules should be cloned out as well; default `True`\n * `DatabaseLog` - `True` or `False`, whether every commit should be logged to the database; (requires a database); default `False`\n * `CronDeployment` - `True` or `False`, whether every commit should be inserted into the database and deployed by cron job instead of being deploying directly; (requires a database); default `False`\n * `Approval` - `True` or `False`, whether every commit has to be first approved in the database and is then deployed by cron job; (requires a database); default `False`\n * `Preprocessing` - space separated list of commands to be performed before deploying any commits; default `` (empty)\n * `Postprocessing` - space separated list of commands to be performed after deploying all commits; default `` (empty)\n\n### Database\n\nTo be able to utilise a database, a `Database` section is required.\nThe `Engine` setting in the `Database` section specified the database backend (must be `sqlite`, `mongodb` or `mysql`).\nEach database backend has its own further options:\n\n\t# MySQL\n\t# Database and table have to be setup, see docs/commits.sql\n\t[Database]\n\tEngine = mysql\n\tHost = localhost\n\tPort = 3306\n\tUser = gitdh\n\tPassword = ###randompassword###\n\tDatabase = gitdh\n\tTable = commits\n\n\t# MongoDb\n\t# Database and collection are created when needed\n\t[Database]\n\tEngine = mongodb\n\tHost = localhost\n\tPort = 27017\n\tDatabase = gitdh\n\tCollection = commits\n\n\t# SQLite\n\t# Is created when needed; DatabaseFile must be writable\n\t[Database]\n\tEngine = sqlite\n\tDatabaseFile = /var/lib/gitolite/data.sqlite\n\tTable = commits\n\n### Commands\n\nCommands used for `Preprocessing` and `Postprocessing` are stored in additional sections in the config file.\nThe section name is the name of the command with trailing `-command`.\n\n\t[crunch-command]\n\tMode = file\n\tRegExp = \\.php$\n\tCommand = eff_php_crunch ${f}\n\n\t[customscript-command]\n\tMode = once\n\tCommand = ${f}/custom.sh\n\n`Mode` can either be `file` or `once`. The `Command` defines the command which is executed.\nIn the `Command` string `${f}` is substituted with a file path:\n\n * If `Mode` equals `file`, the command is performed once for every file in the repository matching the regular expression in the optional `RegExp` option. The file path is the path of the individual file in this case.\n * If `Mode` equals `once`, the command is performed once for the deployed repository, the file path in this case is the path of the deployed repository.\n\nAdditional Options:\n\n * `Shell` - `True` or `False`, whether a shell should be used to execute the command; default `False`\n * `SuppressOutput` - `True` or `False`, whether output from the command should be surpressed, whether ; default `True`\n\n## Setup\n\nIn order to deploy commits automatically, gitdh has to be installed as a git post-receive hook and / or a cron job.\nPost-receive hooks require a local \"git server\" (e.g. [gitolite](http://gitolite.com/)) commits are pushed to.\nCron Jobs have to be created to use advanced features, e.g. deploy commits from `External` repositories or the `Approval` or `CronDeployment` features.\n\nThe `git-dh install` command helps creating these files.\n\n### `postreceive` Setup\n\nThe `git-dh install postreceive` command will assist on creating git post-receive hooks.\n\nThe following command will attempt to create a post-receive hook for every `target` (being a config file or a repository):\n\n\t# git-dh install postreceive \u003ctarget\u003e[ \u003ctarget\u003e[ \u003ctarget\u003e ...]]\n\nThe command will try to fetch all required information from the `target`.\nIt will also attempt to recognise and use the current virtualenv.\nThe command by default doesn't overwrite any files, aborts on error and prints all files written to.\n\nAdditional arguments:\n\n * `--printOnly` - Only print the file content, don't write any files\n * `--force` - Overwrite existing files\n * `--quiet` - Only print errors\n * `--mode` - The mode of the created file; default 755\n\nFor more information see `git-dh install postreceive --help`.\n\nA sample post-receive file can be found in `docs/post-receive.sample`\n\n### `cron` Setup\n\nThe `git-dh install cron` command will assist on creating cron job files in `/etc/cron.d/`.\n\nThe following command will attempt to create a cron job `name` in `/etc/cron.d/` containing commands to query every `target` (being a config file or a repository):\n\n\t# git-dh install cron \u003cname\u003e \u003ctarget\u003e[ \u003ctarget\u003e[ \u003ctarget\u003e ...]]\n\nThe command will try to fetch all required information from the `target`.\nIt will also attempt to recognise and use the current virtualenv.\nThe command by default doesn't overwrite any files, aborts on error and prints all files written to.\n\nAdditional arguments:\n\n * `--user` - The user to execute gitdh under in the cron job; default: the current user\n * `--interval` - The interval with which the cron job is to be executed; default `*/5 * * * *`\n * `--unixPath` - The `PATH` to be written to the cron job file; default: the current path\n * `--mailto` - The `MAILTO` to be written to the cron job file; default root\n * `--printOnly` - Only print the file content, don't write any files\n * `--force` - Overwrite existing files\n * `--quiet` - Only print errors\n * `--mode` - The mode of the created cron job file; default 644\n\nFor more information see `git-dh install cron --help`.\n\nA sample cron job file can be found in `docs/cronjob.sample`\n\n## Issues / Contributing\n\nPlease use the [Git-Deployment-Handler Github Repository](https://github.com/seoester/Git-Deployment-Handler) to submit issues or contribute.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpskopnik%2FGit-Deployment-Handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpskopnik%2FGit-Deployment-Handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpskopnik%2FGit-Deployment-Handler/lists"}