无法在 Azure 静态 Web 应用程序中部署我的 React 应用程序。 Github 操作抛出此日志:

问题描述 投票:0回答:2

一切都运行正常,直到发生这种情况:

npm WARN deprecated [email protected]: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.

added 1654 packages, and audited 1655 packages in 1m

然后,在日志的末尾,我从 Oryx 收到此信息,但我的应用程序没有部署。

---End of Oryx build logs---
Oryx has failed to build the solution.

For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
Exiting

我不知道解决方案是什么。我应该删除 package-lock.json 中警告的依赖项吗? (这就是警告的来源)

我希望像往常一样部署我的应用程序

这是我的工作流程文件:

name: Azure Static Web Apps CI/CD

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

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_HAPPY_SEA_000C4D810 }}
          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: "/" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "build" # 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_HAPPY_SEA_000C4D810 }}
          action: "close"

reactjs azure deployment azure-static-web-app
2个回答
0
投票

我已将 React 应用程序部署到 Azure 静态 Web 应用程序,没有任何问题。 检查以下解决方法。

在本地创建一个 React 应用程序。

npx create-react-app my-react-app

导航到应用程序根目录。

cd my-react-app
npm start
  • 在 GitHub 中创建新的 Repository 并推送本地代码。
  • 您将在GitHub中找到将本地代码推送到存储库的命令。
git init
git add README.md
git commit -m "Update Code"
git branch -M main
git remote add origin https://github.com/Organization/RepositoryName.git
git push -u origin main
  • 在 Azure 门户中创建一个新的
    Static Web App
  • Deployment details
    下,选择
    GitHub Account
    。提供组织、存储库和分支详细信息。

Build details
下提供如下所述。

Build Prests - React
App location - api
Output location - build

点击

Review + create

  • 最初当我运行应用程序时,我得到了内容页面。

enter image description here

  • 导航至
    GitHub
    = >
    Actions
    ,检查构建和部署是否成功。
  • 点击
    Re-run jobs
    .

enter image description here

输出:

请参阅我的 GitHub 存储库


0
投票

我知道这个问题是一年前发布的,但我很想知道这个错误的解决方案。我也面临着同样的问题并且无法解决。我使用 Create React App 创建了一个 ReactJS 应用程序,并将其保存在 GitHub 存储库中。我使用 Azure 门户创建了一个 Azure 静态 Web 应用程序,并链接了用于 CI/CD 的 GitHub。我没有做更多的事情,但我仍然在 GitHub Actions 中遇到构建失败。

© www.soinside.com 2019 - 2024. All rights reserved.