这个 YML 文件有什么问题

What is the issue with this YML file

name: Trigger to QA Repo
on:
  push:
    branches:
      - master
      - newfeature
  pull_request:
    branches:
      - develop
      - master
jobs:
  build:
    env:
      TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Step 1 - Set up JDK 11
        uses: actions/setup-java@v2
        with:
          java-version: '11'
          distribution: 'adopt'
          cache: maven
      - name: run Api
          run: |
            curl -u ":$TOKEN" \
            -X POST \
            -H "Accept: application/vnd.github.v3+json" \
            https://api.github.com/repos/xxx/qa_auto/actions/workflows/myworkflow.yml/dispatches \
            -d '{ "ref": "triggerfromserver" }'

在第 24 行出现错误后出现错误,但我没有看到任何错误。有人可以帮助我吗?

无效的工作流程文件:.github/workflows/workflow_Branch.yml#L24 您的 yaml 语法在第 24 行有错误

问题是你缩进了 run。由于 name 的值不是对象(name 的值为 run Api),因此 run 不能是 name 对象中的键,因此为什么您不能将 run 作为 name 中的键。

我相信这就是您想要的 YAML:

name: Trigger to QA Repo
on:
  push:
    branches:
      - master
      - newfeature
  pull_request:
    branches:
      - develop
      - master
jobs:
  build:
    env:
      TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Step 1 - Set up JDK 11
        uses: actions/setup-java@v2
        with:
          java-version: '11'
          distribution: 'adopt'
          cache: maven
      - name: run Api
        run: |
          curl -u ":$TOKEN" \
          -X POST \
          -H "Accept: application/vnd.github.v3+json" \
          https://api.github.com/repos/xxx/qa_auto/actions/workflows/myworkflow.yml/dispatches \
          -d '{ "ref": "triggerfromserver" }'

此缩进与示例中使用的缩进匹配 here