Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用shell脚本自动化git提交和ssh apache服务器部署?_Git_Apache_Shell_Ssh - Fatal编程技术网

使用shell脚本自动化git提交和ssh apache服务器部署?

使用shell脚本自动化git提交和ssh apache服务器部署?,git,apache,shell,ssh,Git,Apache,Shell,Ssh,我正试图弄清楚如何使用脚本自动化这个过程 我不知道我会用什么,或者怎么做。我正在寻找正确的方向 吉特币: git commit -am "my commit" git pull origin my_branch git push origin my_branch git archive --format zip --output /c/git/(environment)_(date)_(commithash).zip my_branch scp (environment)_(date)_(has

我正试图弄清楚如何使用脚本自动化这个过程

我不知道我会用什么,或者怎么做。我正在寻找正确的方向

吉特币:

git commit -am "my commit"
git pull origin my_branch
git push origin my_branch
git archive --format zip --output /c/git/(environment)_(date)_(commithash).zip my_branch
scp (environment)_(date)_(hash).zip root@12.3.4.56:/var/www/html-(domain)
password123
在apache中:(通常我在…)


为了解释发生了什么,我正在推送我的最新提交,SCPing到apache服务器docroot,部署,并使用提交哈希进行备份。

您可以按计划使用shell脚本——只需将要运行的命令(每行一个)保存在一个文件中,然后添加
#/bin/bash
在顶部,使用
chmod+x myscript.sh
使其可执行(不需要
.sh
文件扩展名),然后使用
/myscript.sh
运行它


您可能会发现使用专门帮助部署的脚手架更容易。使用shell脚本的这些系统(我还没有尝试过)中有一个很好看的是。

您正朝着这个目标迈出第一步

我使用我设置的来执行以下操作:

  • git拉源主机
  • 运行单元测试
  • 部署代码
  • 运行数据库部署
  • 使用成功/失败更新票证系统

还有许多扩展和工具,可用于任何语言等。

你不需要sh,你需要make。查看,它可以轻松地为你自动执行重复任务。你可以创建与Windows等效的Powershell脚本。我找到了一个例子,但你的里程可能会有所不同。
root
password123
cd /var/www/html-(domain)/(environment)
unzip ../(environment)_(date)_(commithash).zip
n
n
A
cd ..
cp -pr (environment) (environment)_(date)_(commithash)
exit