首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将静态HTML网站从Github部署到Azure静态Web应用程序

将静态HTML网站从Github部署到Azure静态Web应用程序
EN

Stack Overflow用户
提问于 2022-06-13 10:38:16
回答 2查看 704关注 0票数 0

我在GitHub中为我的静态网站创建了一个存储库。有一个名为“网站”的文件夹,它包含网站的所有静态html文件。然后,我用GitHub作为源代码,在蔚蓝中安装了一个静态Web

在创建静态web应用程序之后,在我的github存储库中也创建了一个操作,如下所示

代码语言:javascript
运行
复制
name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - main

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GRAY_CLIFF_62B10 }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "/Website" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "wwwroot" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GRAY_CLIFF_62B10 }}
          action: "close"

在我的存储库中,静态网站(HTML)文件位于根中的网站文件夹下。由于我第一次从GitHub部署到Azure中的静态Web,所以我不确定输出位置。所以我刚输入www.root猜测这个文件夹是在我的azure托管位置创建的。但是执行引发了一个错误

应用程序构建未能生成工件文件夹:“www.root”。请确保此属性在您的工作流文件中配置正确。

我不明白我做错了什么。请帮帮忙。在我的假设中,只有一些静态文件,并且假设将html文件复制到我的静态web应用程序的蔚蓝托管区域。此外,我也无法找到我可以从蔚蓝门户获取的信息。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-13 11:51:40

若要解决此The app build failed to produce artifact folder: 'wwwroot'. Please ensure this property is configured correctly in your workflow file.错误,请尝试以下方式:

正如花药耶稣会所建议的

代码语言:javascript
运行
复制
app_location: "/" 
api_location: "" 
app_artifact_location: "wwwroot"
output_location: "./"

你能帮我找一下在azure静态web应用程序中的根文件夹吗?

您可以使用苦斗控制台定位根文件夹。或者,如果使用VS代码,则可以打开.github存储库的根。

参考文献:开始使用Azure静态Web应用程序Azure App服务无法找到根文件夹路径使用Kudu将静态网站发布到Azure App Service

票数 2
EN

Stack Overflow用户

发布于 2022-07-28 14:53:24

我的所有文件都在src文件夹中(我的项目只有HTML和js文件)

这是我的github操作文件:

代码语言:javascript
运行
复制
name: Deploy web app to Azure Static Web Apps

env:
  APP_LOCATION: "src" # location of your client code
  #API_LOCATION: "api" # location of your api source code - optional
  APP_ARTIFACT_LOCATION: "wwwroot" #"build" # location of client code build output

on:
  push:
    branches:
      - main
    paths:
      - 'src/**'
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - main

permissions:
  issues: write
  contents: read

jobs:
  build_and_deploy:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: true
      - name: Build And Deploy
        uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_DESERT_08C538C10 }}
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          action: "upload"
          app_location: ${{ env.APP_LOCATION }}
          #api_location: ${{ env.API_LOCATION }}
          app_artifact_location: ${{ env.APP_ARTIFACT_LOCATION }}

  close:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close
    steps:
      - name: Close
        uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_BRAVE_DESERT_08C538C10 }}
          action: "close"

你还需要把你的Tocken添加到Github的秘密中。

在这里,您将在Azure中的静态Web应用程序资源中获得Tocken

在get之后,您需要插入这是您的秘密,如下:

,请注意秘密名称。需要是你的Github操作文件中的一些.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72601446

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档