这个 YML 文件有什么问题

发布于 2025-01-10 07:54:41 字数 904 浏览 0 评论 0原文

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 第 24 行的 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" }'

Getting error following error on line 24 but I don't see any error. can some one help me in this.

Invalid workflow file: .github/workflows/workflow_Branch.yml#L24
You have an error in your yaml syntax on line 24

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

通知家属抬走 2025-01-17 07:54:41

问题是你缩进了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" }'

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

The problem is you indent run. Since name's value is not an object (name has the value run Api), then run cannot be a key in the name object, hence why you cannot have run as a key in name.

I believe this is the YAML you want:

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" }'

This indentation matches the indentation used in the examples here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文