首页 > 解决方案 > 尝试在 Azure 上部署无框架静态 Web 应用程序时,为什么我会从 GitHub Actions 收到构建错误?

问题描述

我有一个简单的静态网站,我正在尝试使用 GitHub Actions 将其部署为 Azure 静态 Web 应用程序(无框架)。我的目录结构是:

├── .github/workflows/
├── css/
├── img/
├── js/
├ index.html

当我推送到 GitHub 存储库时,Azure 静态 Web 应用程序 CI/CD 操作会启动构建和部署作业。在 .github/workflows 目录中的 YAML 配置文件中,我为我的存储库/构建配置设置了以下内容:

app_location: "/"    # The app source code is in the root directory for the repo
api_location: ""     # There is no API that needs to be configured
output_location: "/" # my index.html file is in the root directory for the repo

但是,我在构建和部署作业中收到以下错误:

未能在应用程序工件文件夹 (/) 中找到默认文件。有效的默认文件:index.html,Index.html。如果您的应用程序包含纯静态内容,请验证您的工作流文件(位于 .github/workflows)中的变量“app_location”是否指向应用程序的根目录。

当我指定 index.html 文件的位置时,为什么会出现此错误?

标签: azureazure-web-app-servicegithub-actions

解决方案


因为部署容器是基于 Ubuntu 的,所以我猜测输出位置可能会与整个系统的根目录混淆。

因此,我将工作流 YAML 文件中的输出位置设置为:

output_location: "./"

通过该更改,构建完成并且静态 Web 应用程序成功部署。


推荐阅读