All Projects β†’ vicenteguerra β†’ Git Deploy

vicenteguerra / Git Deploy

Php Script for Auto-Pull in server (Using WebHook from GitLab, GitHub and Bitbucket)

Projects that are alternatives of or similar to Git Deploy

Git Auto Deploy
Deploy your GitHub, GitLab or Bitbucket projects automatically on Git push events or web hooks
Stars: ✭ 251 (-49.29%)
Mutual labels:  webhook, deployment, deploy, gitlab, bitbucket
Hooka
😎 A webhook server with zero coding
Stars: ✭ 180 (-63.64%)
Mutual labels:  webhook, deployment, trigger, bitbucket
Generic Webhook Trigger Plugin
Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
Stars: ✭ 287 (-42.02%)
Mutual labels:  webhook, trigger, gitlab, bitbucket
Keel
Kubernetes Operator to automate Helm, DaemonSet, StatefulSet & Deployment updates
Stars: ✭ 1,870 (+277.78%)
Mutual labels:  webhook, deployment, trigger
feater
Tool for rapid deployment of selected features of your web application to isolated testing or demo environments.
Stars: ✭ 27 (-94.55%)
Mutual labels:  gitlab, deployment, bitbucket
sre.surmon.me
πŸ’» SRE service for Surmon.me blog.
Stars: ✭ 34 (-93.13%)
Mutual labels:  deployment, webhook, deploy
Skyhook
Parses webhooks and forwards them in the proper format to Discord.
Stars: ✭ 263 (-46.87%)
Mutual labels:  webhook, gitlab, bitbucket
epf-transmitter
astrizhachuk.github.io/epf-transmitter/
Stars: ✭ 32 (-93.54%)
Mutual labels:  gitlab, webhook, deploy
froggit-go
Froggit-Go is a universal Go library, allowing to perform actions on VCS providers.
Stars: ✭ 19 (-96.16%)
Mutual labels:  gitlab, webhook, bitbucket
pm2-githook
receive webhook from github/gitlab and ask pm2 to reload the application for you
Stars: ✭ 39 (-92.12%)
Mutual labels:  gitlab, webhook, bitbucket
Discord-GitLab-Webhook
A Discord bot for using webhooks with GitLab (and extendable for other custom webhooks not yet built into Discord).
Stars: ✭ 35 (-92.93%)
Mutual labels:  gitlab, webhook
gitlab-ci-discord-webhook
β›“ Here's your serverless solution for sending build status from GitLab CI to Discord as webhooks.
Stars: ✭ 32 (-93.54%)
Mutual labels:  gitlab, webhook
myyearwithgit
δ»£η δ»“εΊ“εΉ΄η»ˆζ€»η»“ζŠ₯ε‘Šγ€‚
Stars: ✭ 176 (-64.44%)
Mutual labels:  gitlab, bitbucket
go-scm
Package scm provides a unified interface to multiple source code management systems.
Stars: ✭ 117 (-76.36%)
Mutual labels:  gitlab, bitbucket
liara-cli
The command line interface for Liara
Stars: ✭ 54 (-89.09%)
Mutual labels:  deployment, deploy
snk.dev-assistant
Assistant for code development with advanced machine learning features
Stars: ✭ 14 (-97.17%)
Mutual labels:  gitlab, bitbucket
atlassian-kubernetes
All things Atlassian and Kubernetes
Stars: ✭ 30 (-93.94%)
Mutual labels:  deployment, bitbucket
Github Updater
This WP plugin will update GitHub, Bitbucket, GitLab, and Gitea hosted plugins and themes
Stars: ✭ 2,893 (+484.44%)
Mutual labels:  gitlab, bitbucket
Reviewdog
🐢 Automated code review tool integrated with any code analysis tools regardless of programming language
Stars: ✭ 4,541 (+817.37%)
Mutual labels:  gitlab, bitbucket
Cipi
An Open Source Control Panel for your Cloud! Deploy and manage LEMP apps in one click!
Stars: ✭ 376 (-24.04%)
Mutual labels:  deployment, 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

SSH

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

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", "[email protected]: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

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 & write for both owner and group.

On GitHub | GitLab | Bitbucket

GitHub

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

  • Payload URL: https://www.yoursite.com/git-deploy/deploy.php
  • 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

GitLab

In your repository, navigate to Settings β†’ Integrations, and use the following settings:

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

Example screenshot showing GitLab webhook settings

Bitbucket

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

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

Example screenshot showing Bitbucket webhook settings

Integration with CI/CD

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.


I appreciate the collaboration of @JacobDB

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].