Search code examples
github-actions

Github Actions script error in YAML syntax


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:.


Solution

  • 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!"