使用git和CI进行多站点部署

时间:2021-12-05 03:24:54

Currently, I'm using github to host my code repo and then pushing updates to my sites via copy and pasting files onto the server via FTP. However, the host I'm using allows ssh access there must be an easier way to do this.

目前,我正在使用github托管我的代码repo,然后通过拷贝和粘贴文件到服务器上,将更新推送到我的站点。但是,我正在使用的主机允许ssh访问,必须有一个更简单的方法。

What I'm looking to do is the following:

我想做的是:

  • Set up a Jenkins (a CI) that checks all my code before deploying it live.
  • 设置一个Jenkins(一个CI),在部署它之前检查我的所有代码。
  • Be able to deploy from a single repo to multiple sites.. BUT each site has one or two unique files in them (such as a view with a Google Analytics code in them).
  • 能够从一个repo部署到多个站点。但是每个站点都有一个或两个唯一的文件(例如包含谷歌分析代码的视图)。

From my Google-ing so far I can either deploy via GitHub's webhooks that they offer or doing it through Capistrano.

到目前为止,我可以通过GitHub提供的webhook进行部署,也可以通过Capistrano进行部署。

So, my question is what is the best way to go about setting everything up?

所以,我的问题是什么是建立一切的最佳方式?

NOTE: I'm still a programming n00b so mind anything that I haven't taken into consideration while asking the question

注意:我还是一个n00b编程人员,所以请注意在提问时没有考虑到的任何问题

3 个解决方案

#1


0  

Within your repository, you could have two root level folders. One for the site and one to contain site specific files. For each site, create a Jenkins build configuration to perform the following:

在存储库中,可以有两个根级文件夹。一个用于站点,另一个用于包含站点特定的文件。对于每个站点,创建一个Jenkins构建配置来执行以下操作:

  1. Checkout code of your git repository
  2. git存储库的签出代码
  3. Perform any build actions
  4. 执行任何建设行动
  5. Copy site files across to production
  6. 将站点文件复制到生产环境中
  7. Copy site specific files to production
  8. 将站点特定的文件复制到生产中

#2


0  

You can use a local repository that has a clean script which will change the settings in those specific files as you want when checking out a version.

您可以使用具有干净脚本的本地存储库,它将在检查版本时根据需要更改这些特定文件中的设置。

This is covered in the git attributes chapter in the keyword expansion section of the Pro Git book:

这是在git的关键字扩展部分的git属性章节中介绍的:

http://git-scm.com/book/en/Customizing-Git-Git-Attributes

http://git-scm.com/book/en/Customizing-Git-Git-Attributes

#3


0  

You might find it simpler to just use git-ftp for uploading your changes. This script stores the name of the last uploaded commit on the server in a special file, and when you re-upload, it sends only the files which have been changed since the state which has been uploaded last. Things like file/directory renames/deletions are handled properly as well. In our setup, we found this script easier to use than rolling some higher-profile solutions.

您可能会发现,使用git-ftp上传更改会更简单。这个脚本将最近一次上传的提交的名称存储在一个特殊的文件中,当您重新上传时,它只发送自上次上传的状态以来更改过的文件。文件/目录重命名/删除之类的东西也处理得很好。在我们的设置中,我们发现使用这个脚本比使用一些更高级的解决方案更容易。

#1


0  

Within your repository, you could have two root level folders. One for the site and one to contain site specific files. For each site, create a Jenkins build configuration to perform the following:

在存储库中,可以有两个根级文件夹。一个用于站点,另一个用于包含站点特定的文件。对于每个站点,创建一个Jenkins构建配置来执行以下操作:

  1. Checkout code of your git repository
  2. git存储库的签出代码
  3. Perform any build actions
  4. 执行任何建设行动
  5. Copy site files across to production
  6. 将站点文件复制到生产环境中
  7. Copy site specific files to production
  8. 将站点特定的文件复制到生产中

#2


0  

You can use a local repository that has a clean script which will change the settings in those specific files as you want when checking out a version.

您可以使用具有干净脚本的本地存储库,它将在检查版本时根据需要更改这些特定文件中的设置。

This is covered in the git attributes chapter in the keyword expansion section of the Pro Git book:

这是在git的关键字扩展部分的git属性章节中介绍的:

http://git-scm.com/book/en/Customizing-Git-Git-Attributes

http://git-scm.com/book/en/Customizing-Git-Git-Attributes

#3


0  

You might find it simpler to just use git-ftp for uploading your changes. This script stores the name of the last uploaded commit on the server in a special file, and when you re-upload, it sends only the files which have been changed since the state which has been uploaded last. Things like file/directory renames/deletions are handled properly as well. In our setup, we found this script easier to use than rolling some higher-profile solutions.

您可能会发现,使用git-ftp上传更改会更简单。这个脚本将最近一次上传的提交的名称存储在一个特殊的文件中,当您重新上传时,它只发送自上次上传的状态以来更改过的文件。文件/目录重命名/删除之类的东西也处理得很好。在我们的设置中,我们发现使用这个脚本比使用一些更高级的解决方案更容易。