Github Actions脚本中的YAML语法错误

huangapple go评论58阅读模式
英文:

Github Actions script error in YAML syntax

问题

I see an error in your YAML document near the line saying unique-test:. It seems like there's a typo in the word "error" as "errror." Here's the corrected YAML code:

name: Test

on:
  workflow_call:
    secrets:
      MY_SECRET:
        required: true

jobs:
  shared-setup:
    uses: *****/*****/.github/workflows/shared-setup.yml@main

  unique-test:
    runs-on: ubuntu-latest
    needs: shared-setup

    env:
      SUPER_SECRET: ${{ secrets.MY_SECRET }}

    - name: Do something
      run: echo "Hello World!"

I've corrected the typo, replacing "errror" with "error."

英文:
name: Test

on:
  workflow_call:
    secrets:
      MY_SECRET:
        required: true

jobs:
  shared-setup:
    uses: *****/*****/.github/workflows/shared-setup.yml@main

  unique-test:
    runs-on: ubuntu-latest
    needs: shared-setup

    env:
      SUPER_SECRET: ${{ secrets.MY_SECRET }}

    - name: Do something
      run: echo "Hello World!"

I seem to have an errror in my YAML doc. but I can't see it. Deploying to GitHub results in an error that the document has an error in the yaml syntax near the line saying unique-test:.

答案1

得分: 1

缺少第二个作业(unique-test)中的 steps 部分。

我相信在第一个作业中,您故意删除了 uses 的用户名/存储库信息。一旦添加了 steps 键并将那些星号替换为有效值,它应该可以正常工作。

已修复的工作流(linted):

name: Test

on:
  workflow_call:
    secrets:
      MY_SECRET:
        required: true

jobs:
  shared-setup:
    uses: username/repo/.github/workflows/shared-setup.yml@main

  unique-test:
    runs-on: ubuntu-latest
    needs: shared-setup

    env:
      SUPER_SECRET: ${{ secrets.MY_SECRET }}

    steps:
    - name: Do something
      run: echo "Hello World!"
英文:

Missing steps in your second job i.e. unique-test.

I believe that in your first job, you deliberately redacted the username/repo for uses. Once the steps key is added and those asterisks are replaced with valid values, it should work fine.

Fixed workflow (linted):

name: Test

on:
  workflow_call:
    secrets:
      MY_SECRET:
        required: true

jobs:
  shared-setup:
    uses: username/repo/.github/workflows/shared-setup.yml@main

  unique-test:
    runs-on: ubuntu-latest
    needs: shared-setup

    env:
      SUPER_SECRET: ${{ secrets.MY_SECRET }}

    steps:
    - name: Do something
      run: echo "Hello World!"

答案2

得分: 0

你可以使用在线工具,如yaml checker,或者GitHub工作流中的编辑器。这非常有帮助。

  1. shared-setupuses应该是字符串,你可以使用``(反引号)或''
  2. 你必须将process放在steps之下。

结果应该如下所示:

name: Test

on:
  workflow_call:
    secrets:
      MY_SECRET:
        required: true

jobs:
  shared-setup:
    uses: '*****/*****/.github/workflows/shared-setup.yml@main'

  unique-test:
    runs-on: ubuntu-latest
    needs: shared-setup    
    steps:
      - name: Do something
        run: echo "Hello World!"
        env:
          SUPER_SECRET: ${{ secrets.MY_SECRET }}

请注意,我只翻译了你提供的内容,没有添加其他内容。

英文:

you can use online tool like yaml checker or editor in the github workflow it self. and it's quite helpful.

  1. the uses of shared-setup should be in string, you can use `` | ''
  2. you have to put the process below steps,

the result should be like:

name: Test

on:
  workflow_call:
    secrets:
      MY_SECRET:
        required: true

jobs:
  shared-setup:
    uses: '*****/*****/.github/workflows/shared-setup.yml@main'

  unique-test:
    runs-on: ubuntu-latest
    needs: shared-setup    
    steps:
      - name: Do something
        run: echo "Hello World!"
        env:
          SUPER_SECRET: ${{ secrets.MY_SECRET }}

huangapple
  • 本文由 发表于 2023年2月26日 21:59:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/75572493.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定