关闭 Azure 静态 Web 应用程序的拉取请求 github 操作

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

我使用以下指南为部署到azure静态Web应用程序的应用程序设置github操作。在关闭拉取请求的工作流程的最后一部分中

close_pull_request:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request
    steps:
      - name: Close Pull Request
        uses: Azure/static-web-apps-deploy@1a947af9992250f3bc2e68ad0754c0b0c11566c9
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
          action: "close"

我遇到错误了

缺少所需的输入

app_location

我没有看到所提供的指南中提到的任何内容,我不确定为什么我需要提供应用程序位置来关闭拉取请求

关闭 PR 时需要执行的正确操作是什么?

注意:为了澄清 github 操作,当我在编辑器中打开它时运行它,我收到一条错误,指出它丢失了

github-actions azure-static-web-app
1个回答
0
投票

您遇到的错误是由于未在 YML 文件中提供

app_location: "<path_to_your_app>"
导致的。

  • 请参阅此 MSDoc 以获取工作流程文件中可用配置设置的列表。有关详细信息,请参阅示例配置文件。

  • 我已将示例 React 应用程序部署到静态网络。

  • 根据链接配置了Azure Static Web Apps,并在根文件夹中添加了

    staticwebapp.config.json

staticwebapp.config.json

{
  "navigationFallback": {
    "rewrite": "index.html"
  }
}
  • 下面是我的静态 Web 应用程序的 YML 文件; 根据您的文件夹结构替换
    app_location
  • 由于我的 yml 文件位于根目录中,所以我将 app_loaction 设置为
    app_location: "/"

我的 YML 文件:

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@v3
        with:
          submodules: true
          lfs: false
      - 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_PROUD_SKY_0046A9D0F }}
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          action: "upload"
        
        
          app_location: "/"
          api_location: "" 
          output_location: "build" 
         

  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_PROUD_SKY_0046A9D0F }}
          action: "close"

部署状态:

enter image description here

enter image description here

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