简体   繁体   English

Azure Static Web 通过 GitHub 部署的应用程序 (.yml) 在私有 npm 包上出现 404 错误

[英]Azure Static Web App deploying via GitHub Actions (.yml) errors with 404 on private npm packages

I have an Angular app in GitHub that is deploying to an Azure Static Web App via GitHub actions.我在 GitHub 中有一个 Angular 应用程序正在通过 GitHub 操作部署到 Azure Static Web 应用程序。

The deploy fails when I add a private npm package.当我添加私有 npm package 时部署失败。

In GitHub Docs I found how to specify an npm token for a node script via environment setting, and have combined this with Azure's docs on customizing the workflow file, which led me to try this (and a few variations of it):在 GitHub 文档中,我找到了如何通过环境设置为节点脚本指定 npm 令牌,并将其与 Azure 关于自定义工作流文件的文档相结合,这让我尝试了这个(以及它的一些变体):

  - 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_RANDOM }}
      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: "dist" # Built app content directory - optional
      ###### End of Repository/Build Configurations ######
    env:
      NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

The last line with NODE_AUTH_TOKEN I had read would generate an.npmrc file that would authenticate the process.我读过的带有 NODE_AUTH_TOKEN 的最后一行将生成一个 .npmrc 文件来验证进程。 I have a GitHub secret called NPM_TOKEN containing a token I generated in npm, selecting the 'for CI purposes' option.我有一个名为 NPM_TOKEN 的 GitHub 秘密,其中包含我在 npm 中生成的令牌,选择“用于 CI 目的”选项。

But I am still seeing the 404 error when attempting to install the private package.但是我在尝试安装私有 package 时仍然看到 404 错误。

Any ideas would be appreciated!任何想法,将不胜感激!

Found this post on medium: Install private NPM packages in github actions在媒体上找到这篇文章: Install private NPM packages in github actions

Following the advice there I "manually" created the.npmrc file before calling the azure deploy action and that solved it:按照那里的建议,我在调用 azure 部署操作之前“手动”创建了 .npmrc 文件并解决了它:

      - name: Create .npmrc file
        run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        .......

暂无
暂无

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

相关问题 通过 Github 操作将 node.js 部署到 azure web 应用程序,由于我引用的一些错误和下面的屏幕截图,我的构建一直失败。 请与泰 - Deploying node.js to azure web app Via Github Actions, I keep failing my build due to some error that i quoted and screenshot below. Please & Ty 通过Github部署Django App到Azure时禁用collectstatic命令 - Disable collectstatic command when deploying Django App to Azure via Github Symfony 缓存:在 Azure web 应用程序中清除 GitHub 操作 - Symfony cache:clear in Azure web app with GitHub Actions 通过 Bicep 部署 Azure Web App 未设置 Stack - Deploying an Azure Web App via Bicep does not set Stack 使用 Github 操作将 Next.js 部署到 Azure 应用程序服务时出现问题 - Problem with Deploying Next.js to Azure App Service using Github Actions 获取部署 url 以传递给下一步 - Azure Static Web 具有 Github 操作的应用程序 - Get deployment url to be passed to next step - Azure Static Web apps with Github actions 如何从公共 azure 私人存储帐户连接到 azure static web 应用程序 - How to connect to a azure private storage account from a public azure static web app 错误 GitHub 操作部署到 Azure Web 应用程序 - Error with GitHub Action Deploy to Azure Web App 使用 GitHub 操作部署到 GCloud VM 实例 - Deploying to GCloud VM Instances with GitHub Actions 作为一个组织,你如何发布和安装私有的 npm package 到 GitHub 包? - How do you publish and install a private npm package to GitHub packages as an organisation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM