使用 ZIP 部署进行 Azure Web 应用程序部署期间,GitHub Actions 管道失败

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

当我使用时:

yaml

  • 名称:用于部署的 Zip 工件 运行: zip -r release.zip ./* -x "logs/" ".env" "node_modules/"

在Azure Web App中,我已将环境变量SCM_DO_BUILD_DURING_DEPLOYMENT设置为true,在部署阶段我在GitHub Actions管道中遇到以下错误:

运行 azure/webapps-deploy@v2 使用 ZIP Deploy 启动包部署。 正在获取更改。 清理以前的 zip 部署中的临时文件夹,并将推送的 zip 文件 /tmp/zipdeploy/a004467d-fb80-4497-b589-d18842459ba6.zip (7.96 MB) 提取到 /tmp/zipdeploy/extracted 错误:无法将 Web 包部署到应用服务。 错误:部署失败,使用 ZIP 部署的包部署失败。请参阅日志了解更多详细信息。

如何解决这个错误

azure
1个回答
0
投票

我尝试了示例代码,并通过 GitHub 管道将

@Run azure/webapps-deploy@v2
-   name: Zip artifact for deployment run: zip -r release.zip ./* -x "logs/_" ".env" "node_modules/_"
添加到 yml 文件中,部署到 Azure Web App,正如您在问题中提到的那样。

然后我得到了同样的错误,为了避免该错误,我在 GitHub Workflow 文件中将

@Run azure/webapps-deploy@v2
更改为
@Run azure/webapps-deploy@v3

下面是我完整的工作流程文件。

GitHub 工作流程文件:

name: Build and deploy Node.js app to Azure Web App - kareactapp24
on:
  push:
    branches:
      - main
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Node.js version
        uses: actions/setup-node@v3
        with:
          node-version: '18.x'
      - name: npm install, build, and test
        run: |
          npm install
          npm run build --if-present
      - name: Zip artifact for deployment
        run: zip -r release.zip ./* -x "logs/" ".env" "node_modules/"
      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v4
        with:
          name: node-app
          path: release.zip
  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v4
        with:
          name: node-app
      - name: Unzip artifact for deployment
        run: unzip release.zip
      - name: 'Deploy to Azure Web App'
        id: deploy-to-webapp
        uses: azure/webapps-deploy@v3
        with:
          app-name: 'kareactapp24'
          slot-name: 'Production'
          package: .
          publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_2CE09B03382F4CEE9BF83130962DD932 }}

将v2更改为v3后,部署成功。

enter image description here

Azure Web 应用程序输出

enter image description here

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