skip to Main Content
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:.

2

Answers


  1. 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 }}
    
    Login or Signup to reply.
  2. 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!"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search