[英]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.