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

发布于 2025-02-06 20:26:14 字数 2585 浏览 3 评论 0原文

我在Github为静态网站创建了一个存储库。那里有一个名为网站的文件夹,它包含该网站的所有静态HTML文件。然后,我用github在Azure中设置了一个静态Web应用程序,作为源

“在此处输入映像”

立即创建静态Web应用程序后,

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"

在我的GitHub存储库中也可以在我的静态网站(html) 中创建一个操作。文件位于root的网站文件夹下。由于我首先从GitHub部署到Azure中的静态Web应用程序,因此我不确定输出位置。因此,我刚刚进入wwwroot,猜测这个文件夹在我的Azure托管位置中创建。但是执行发出了错误

应用程序构建未能生成伪影文件夹:'wwwroot'。请 确保在工作流文件中正确配置此属性。

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

I have created a repository in GitHub for my static website. There a Folder called website and it contains all the static html files for the website. Then I setup a Static Web App in azure with GitHub as source

enter image description here

Immediately upon creating the static web app, one action also got created in my github repository like this

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"

Here in my repository the static website (HTML) files are under Website folder in Root. Since I am first to the deploy from GitHub into Static Web App in Azure, I was not sure about the output location. So I just entered wwwroot guessing this folder get created in my azure hosting location. But the execution fired an error

The app build failed to produce artifact folder: 'wwwroot'. Please
ensure this property is configured correctly in your workflow file.

I didnt understand what I did wrong. Please help. In my assumption there was just some static files and it was suppposed to copy the html files into my azure hosting region of my static web app. Also I am not able to locate where that information i can fetch from azure portal.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迟月 2025-02-13 20:26:17

为了解决此,应用程序构建未能产生伪影文件夹:'wwwroot'。请确保在工作流文件中正确配置此属性。错误,尝试以下方式:

anthonychu jesuisme

app_location: "/" 
api_location: "" 
app_artifact_location: "wwwroot"
output_location: "./"

您能帮助我如何在Azure静态Web应用中找到根文件夹

您可以使用 kudu控制台找到根文件夹。另外,如果使用VS代码,则可以打开 .github 存储库。

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

To resolve this The app build failed to produce artifact folder: 'wwwroot'. Please ensure this property is configured correctly in your workflow file. error, try following way:

As suggested by anthonychu and Jesuisme:

app_location: "/" 
api_location: "" 
app_artifact_location: "wwwroot"
output_location: "./"

could you please help me how can I locate the root folder in azure static web app

You can use Kudu console to locate the root folder. Alternatively, if you are using VS Code, then you can open the root of your .github repository.

References: Getting Started with Azure Static Web Apps, Azure App service not able to find root folder path and Use Kudu to Publish Static Website to Azure App Service

草莓味的萝莉 2025-02-13 20:26:17

我在SRC文件夹中有所有文件(我的项目只有HTML ANS JS文件)

,这是我的GitHub操作文件:

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"

您仍然需要在GitHub Secret中添加托克。

中,您将在静态Web应用程序资源中获得托管

在这里,您将在Azure Cloud

获得后,您需要插入这是您的秘密,例如:

​,秘密名称的关注。需要是您的github操作文件中的某些。

I have all my files in src folder (my project only have HTML ans js files)

and here is my github actions file:

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"

You still need to add your Tocken in Github Secrets.

Here you will get the Tocken in your Static Web App resource in Azure Cloud

enter image description here

After get, you need to insert this is your secrets, like this:

enter image description here

Please, attenttion on Secret Name. Needs to be the some on your Github Actions file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文