简体   繁体   English

如何从 github 构建文件夹部署到托管服务器?

[英]How can i deploy from github build folder to hostinger server?

I have a project which have directory structure like below and i am hosting the application on Hostinger.我有一个目录结构如下的项目,我在 Hostinger 上托管该应用程序。

项目结构

The problem is I don't want to deploy the complete code to the server.问题是我不想将完整的代码部署到服务器。 I want to deploy only the build folder which contains required code only.我只想部署仅包含所需代码的构建文件夹。

There is only option to give the GitHub project URL. How can I deploy from a specific folder?只有给 GitHub 项目 URL 的选项。我如何从特定文件夹部署?

As mentioned in hostinger/example-app , you can only specify the GitHub repo and URL.正如在hosts/example-app 中提到的,您只能指定 GitHub 存储库和 URL。

If possible you could consider then using two GitHub repos:如果可能,您可以考虑使用两个GitHub 存储库:

  • one for your main project一个用于您的主要项目
  • one with the necessary code一个带有必要代码的

And you would reference the second inside the first with a git submodule add .您可以使用git submodule add引用第一个中的第二个。
That way:那样:

  • cloning the first repo would still get the second one content.克隆第一个 repo 仍然会得到第二个内容。
  • you can specify the URL of the second repo (the one with only the necessary code to deploy) in hostinger .您可以在hostinger指定第二个 repo(只有需要部署的代码的hostinger )的hostinger

You can also use apache's .htaccess feature to tweak hosting settings, which is fully supported in hostinger.您还可以使用 apache 的 .htaccess 功能来调整托管设置,hostinger 完全支持该功能。

Create an .htaccess file in the root of your repo with the contents:在您的存储库的根目录中创建一个 .htaccess 文件,其内容如下:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !path-to-your-webroot/
RewriteRule (.*) path-to-your-webroot/$1 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 dist 文件夹在 GitHub 页面上部署项目 - How to deploy a project on GitHub Pages from dist folder 如何为我的 Github 操作找到正确的入站规则以部署在我的 AWS EC2 服务器上? - How can I find the right inbound rule for my Github action to deploy on my AWS EC2 server? 我可以部署一个前端文件夹和后端文件夹都在同一个 Github 存储库上的 MERN 应用程序吗? - Can I deploy a MERN app whose both frontend folder and backend folder are on the same Github repo? 如何删除 github 上的文件或文件夹? - how can i delete a file or folder on github? 我如何找到新推送代码到 github 的人的用户名/详细信息? 我正在使用 jenkins 管道来构建和部署 - How can i find username/details of people who newly pushed code to github? I am using jenkins pipeline to build and deploy 我如何让github从master分支中的文件夹自动构建项目页面? - How do I have github build a project page automatically from a folder in the master branch? 如何将托管域与 github 页面一起使用 - How to use hostinger domain with github pages 如何将 Express 服务器部署到 GitHub 页面? - How do I deploy an Express server to GitHub Pages? 如何将 Jekyll 站点从 github repo 部署到我的 ftp? - How can I deploy Jekyll site from github repo to my ftp? Github 操作 - 如何构建和部署推主 - Github Actions - How to Build and Deploy on push to master
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM