[英]How can I use git to deploy to test server?
I have used redhat's open shift few years ago. 几年前,我曾使用过redhat的开放式班次。 The way you update the server is by pushing to the git repo.
更新服务器的方法是通过推送到git repo。 Once you pushed your changes, you can test your app in the browser.
推送更改后,您可以在浏览器中测试您的应用。
I want to implement that in one of my VM for testing. 我想在我的一个虚拟机中实施该测试。 So that whenever I pushed to the repo, the testers can see my changes right away.
这样,每当我推送到仓库时,测试人员就可以立即看到我的更改。 I'm doing it in a cloud VM because the person who will test it is in another country.
我正在云VM中进行测试,因为要进行测试的人员在另一个国家。 I'm using nginx, pm2, nodejs and express.
我正在使用nginx,pm2,nodejs和express。
I understand that I can just ssh to the server, pull the changes, restart pm2. 我了解我可以SSH到服务器,进行更改,重新启动pm2。 But if there's a more automated way, that will be better.
但是,如果有一种更自动化的方法,那会更好。
What you're describing is called Continuos Integration/Continuous Deployment, often referred to as CI/CD. 您所描述的称为连续集成/连续部署,通常称为CI / CD。 There are tools specifically made for this.
有专门为此目的设计的工具。 The two major players are TeamCity by jetbrains (free to use for the size of project your describing) and Jenkins (open source).
两个主要参与者是jetbrains的TeamCity(根据您描述的项目大小免费使用)和Jenkins(开源)。 I would suggest you search for tutorials on CI/CD that use one of those two products.
我建议您搜索使用这两种产品之一的CI / CD教程。
You probably want to look into the server side git hooks. 您可能想研究服务器端的git挂钩。 You can execute a bash script on the server when a git push is received, and execute whatever needs to happen to update the server.
您可以在收到git push时在服务器上执行bash脚本,并执行更新服务器所需的一切。
To give a quick rundown: 简要介绍一下:
Hooks can be found under .git/hooks
. 钩子可以在
.git/hooks
下找到。 Here you will find the following files: 在这里您将找到以下文件:
To give an example, on your server if you add the following to your post-update hook, the server will send you an email whenever a commit is received: 举个例子,在服务器上,如果将以下内容添加到更新后挂钩中,则服务器将在收到提交时向您发送电子邮件:
#!/bin/bash
git show --name-status | mail -s "Received Push" youremail@email.com
In this file, is where you will likely want to write your script to rebuild the website with the newly received data! 在此文件中,您可能想编写脚本以使用新接收的数据重建网站!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.