【发布时间】:2021-11-24 15:14:49
【问题描述】:
我有一个 bitbucket 存储库,其中包含运行我的个人网站所需的所有网站文件。当我对我的主分支进行更改时,有没有办法让我的网络服务器 pc 上的本地文件夹自动同步到我的仓库?我目前正在使用 U 盘来合并 PC 之间的更改,而且工作量更大。
TLDR;基本上,我想编写代码 > 提交给 master > 从 chrome 上的网络服务器加载站点 > 存在更改。
【问题讨论】:
我有一个 bitbucket 存储库,其中包含运行我的个人网站所需的所有网站文件。当我对我的主分支进行更改时,有没有办法让我的网络服务器 pc 上的本地文件夹自动同步到我的仓库?我目前正在使用 U 盘来合并 PC 之间的更改,而且工作量更大。
TLDR;基本上,我想编写代码 > 提交给 master > 从 chrome 上的网络服务器加载站点 > 存在更改。
【问题讨论】:
您应该看看 github 操作。我使用这些来确保我所做的每一次提交都没有通过构建和运行单元测试而退化。自动化部署过程也相当简单。
【讨论】:
您可以使用 bitbucket 管道(github 操作的 bitbucket 版本)来自动化您的部署过程:
bitbucket-pipelines.yml,示例内容:image: atlassian/default-image:2
pipelines:
branches:
master:
- parallel:
- step:
name: 'Automated Deployment'
script:
- curl https://your.web.server.com/automated_deployment.php
automated_deployment.php 具有这样的内容:<?php
shell_exec('cd /var/www/myproject && git pull');
这样的设置意味着:
curl https://your.web.server.com/automated_deployment.php
automated_deployment.php,这将调用cd /var/www/myproject && git pull
https://your.web.server.com/automated_deployment.php 存储在 bitbucket 存储库变量中(因此相同的 bitbucket-pipelines.yml 文件可用于多个项目)automated_deployment.php 的客户端证书(因此并非互联网上的每个人都可以在您的服务器上调用https://your.web.server.com/automated_deployment.php(或仅使用秘密密码)【讨论】: