{"id":20490035,"url":"https://github.com/vitorfs/gitd","last_synced_at":"2026-04-15T22:35:13.733Z","repository":{"id":147873448,"uuid":"308906887","full_name":"vitorfs/gitd","owner":"vitorfs","description":"Git Deployments","archived":false,"fork":false,"pushed_at":"2020-11-02T02:22:23.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-09T08:58:07.966Z","etag":null,"topics":["deployment","django","github","python","webhooks"],"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/vitorfs.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-31T15:02:29.000Z","updated_at":"2023-08-22T14:29:48.000Z","dependencies_parsed_at":"2023-05-27T18:30:40.383Z","dependency_job_id":null,"html_url":"https://github.com/vitorfs/gitd","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/vitorfs/gitd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorfs%2Fgitd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorfs%2Fgitd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorfs%2Fgitd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorfs%2Fgitd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitorfs","download_url":"https://codeload.github.com/vitorfs/gitd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorfs%2Fgitd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31863495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["deployment","django","github","python","webhooks"],"created_at":"2024-11-15T17:15:15.157Z","updated_at":"2026-04-15T22:35:13.703Z","avatar_url":"https://github.com/vitorfs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Deployments\n\nA minimal Django app to handle GitHub webhooks and start deployments on self-hosted applications.\n\n## Usage\n\nOn your server, start by creating a directory to install the **gitd** utility:\n\n```\nmkdir /opt/gitd\n```\n\nInside the **/opt/gitd** directory, clone the repository using git:\n\n```\ngit clone https://github.com/vitorfs/gitd.git\n```\n\nCreate a virtualenv to install the dependencies using Python 3:\n\n```\nvirtualenv venv -p python3\n```\n\nActivate the venv:\n\n```\nsource venv/bin/activate\n```\n\nGo to the git repository directory:\n\n```\ncd /opt/gitd/gitd\n```\n\nInstall the dependencies:\n\n```\npip install -r requirements/production.txt\n```\n\nMigrate the SQLite database:\n\n```\npython manage.py migrate\n```\n\nCreate a .env file to add your configuration:\n\n**.env**\n\n```\nSECRET_KEY=CREATE_A_LONG_AND_RANDOM_STRING\nDEBUG=False\nALLOWED_HOSTS=.example.com\nTIME_ZONE=UTC\nLANGUAGE_CODE=en-us\nGITHUB_WEBHOOK_KEY=YOUR_SECRET_GITHUB_KEY_HERE\nGITHUB_REPOSITORY=example/hello-world\nGITHUB_BRANCH=refs/heads/main\nGITD_DEPLOYMENT_COMMAND=/opt/gitd/deploy\n```\n\nInside the **/opt/gitd** directory, add a **run** and **logs** directory:\n\n```\nmkdir run logs\n```\n\nInitialize a log file for the Gunicorn worker:\n\n```\ntouch logs/gitd-worker.log\n```\n\nAdd a **gunicorn_start** script inside **/opt/gitd**:\n\n```\ntouch gunicorn_start\n```\n\nAdd the commands to start the Gunicorn worker:\n\n```\n#!/bin/bash\n\nNAME=\"gitd\"\nDIR=/opt/gitd/gitd\nUSER=ubuntu\nGROUP=ubuntu\nWORKERS=3\nBIND=unix:/opt/gitd/run/gunicorn.sock\nDJANGO_SETTINGS_MODULE=gitd.settings.production\nDJANGO_WSGI_MODULE=gitd.wsgi\nLOG_LEVEL=error\n\nsource /opt/gitd/venv/bin/activate\n\nexport DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE\nexport PYTHONPATH=$DIR:$PYTHONPATH\n\nexec /opt/gitd/venv/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \\\n  --name $NAME \\\n  --workers $WORKERS \\\n  --user=$USER \\\n  --group=$GROUP \\\n  --bind=$BIND \\\n  --log-level=$LOG_LEVEL \\\n  --log-file=-\n```\n\nNote that you may need to change the `USER` and `GROUP` but it needs to have higher privilege as the worker may need to execute commands on the machine to start the deployment.\n\nMake it executable:\n\n```\nchmod u+x gunicorn_start\n```\n\nAdd your deployment script:\n\n```\ntouch deploy\n```\n\n```\n#!/bin/bash\n\nsu - example_user -c \"git -C ~/example_app pull origin master\"\nsu - example_user -c \"~/venv/bin/pip install -r ~/example_app/requirements.txt\"\nsu - example_user -c \"~/venv/bin/python ~/example_app/manage.py migrate\"\nsu - example_user -c \"~/venv/bin/python ~/example_app/manage.py collectstatic --noinput\"\n\nsudo supervisorctl restart example_app\n\nexit 0\n```\n\nMake it executable:\n\n```\nchmod u+x deploy\n```\n\nThe contents of the `deploy` script really depends on what kind of app you are running, what routines you must run upon a new deploy. So it is up to you to create this file. The example above is a script for deploying a Django application.\n\nUpdate your NGINX/Apache conf to handle requests to `__gitd__` path, the example below it is a configuration for NGINX:\n\n```\nupstream gitd_app_server {\n    server unix:/opt/gitd/run/gunicorn.sock fail_timeout=0;\n}\n\nserver {\n    ...\n\n    location /__gitd__/ {\n        proxy_set_header Host $http_host;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_redirect off;\n        proxy_pass http://gitd_app_server;\n    }\n\n    ...\n}\n```\n\nHere we are making use for the apps own IP address or domain.\n\nNow we can use supervisor to monitor and start the `gunicorn_start` command if the server reboots.\n\n```\nsudo apt-get -y install supervisor\nsudo systemctl enable supervisor\nsudo systemctl start supervisor\n```\n\nCreate a supervisor conf file:\n\n**/etc/supervisor/conf.d/gitd.conf**\n\n```\n[program:gitd]\ncommand=/opt/gitd/gunicorn_start\nuser=ubuntu\nautostart=true\nautorestart=true\nredirect_stderr=true\nstdout_logfile=/opt/gitd/logs/gitd-worker.log\n```\n\nRun the supervisor commands to discover the new app:\n\n```\nsupervisorctl reread\nsudo supervisorctl update\n```\n\nRestart the web server (NGINX in our example):\n\n```\nsudo service nginx restart\n```\n\nNow your server is ready to receive webhooks to initialize a deployment.\n\nBy now you may have realised that perhaps this is not the easiest solution to automate deploys. But I can't help, I like writing stuff with Django.\n\n## License\n\nThe source code is released under the [MIT License](https://github.com/vitorfs/gitd/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorfs%2Fgitd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitorfs%2Fgitd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorfs%2Fgitd/lists"}