【发布时间】:2015-11-02 13:32:09
【问题描述】:
我有一个服务器设置为“生产”远程,它运行一个接收后的 shell 脚本来部署站点,并为主分支进行“硬”部署。或者将 dev 分支的“软”部署到不同的目录。
soft (fast, low resources) - checks out the work-tree to the /dev directory (fast)
hard (slower, more resources) - check out the work-tree to a new '/temp' directory,
copies the non-tracked files from the '/live' directory to '/temp' (can be large)
if successful, renames the '/live' directory to '/live-old'
renames the '/temp' to '/live' and deletes the older '/live-old' directory
有时我只想在主分支推送上进行“软”部署,如果它像修补程序这样微小的东西,因为硬部署可能需要一段时间来复制上传等未跟踪的文件,并且似乎浪费服务器资源说如果为不同的应用程序做多个修补程序。
我可以将一个变量从我的本地服务器(如 git 配置文件的远程部分)传递到远程服务器,以告诉它为 master 分支进行软部署还是硬部署?
我在想远程服务器是否知道本地远程名称是什么,或者我可以在远程定义中向 url 添加一个变量,例如:
[remote "production-hard"]
url = ssh://project.git?deploy=hard
fetch = +refs/heads/*:refs/remotes/production/*
[remote "production-soft"]
url = ssh://project.git?deploy=soft
fetch = +refs/heads/*:refs/remotes/production/*
我确信这种方式可能行不通,但希望你能理解我想要做什么。
另外,请说这是否真的是不好的做法,我应该使用另一种方法。
谢谢。
【问题讨论】:
标签: git deployment version-control web-deployment git-post-receive