• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

vicenteguerra/git-deploy: Php Script for Auto-Pull in server (Using WebHook from ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

vicenteguerra/git-deploy

开源软件地址:

https://github.com/vicenteguerra/git-deploy

开源编程语言:

PHP 100.0%

开源软件介绍:

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 $USER:webserverusername custom-project-repo-dir/.git/ to change the group of the repo.
  3. run sudo chmod -R g+s custom-project-repo-dir/.git/ to make the group assignment inherited for new files/dirs.
  4. run sudo chmod -R 775 custom-project-repo-dir/.git/ 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:


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap