Search code examples
githubyamlgithub-actionsgithub-api

Where actually is the syntax error in my github actions yml file


I am actually implementing CI/CD for my application. I want to start the application automatically using pm2. So I am getting the syntax error on line 22.

This is my yml file enter image description here

This is the error I am getting on github

enter image description here


Solution

  • The problem in the syntax here is related to how you used the - symbol.

    With Github actions, you need at least a run or uses field inform for each step inside your job, at the same level of the name field (which is not mandarory), otherwise the github interpreter will return an error.

    Here, from line 22, you used something like this:

    - name: ...
      - run: ...
      - run: ...
      - run: ...
    

    So there are two problems:

    • First, the name and the run field aren't at the same yaml level.
    • Second, your step with the name field doesn't have a run or uses field associated with it (you need at least one of them).

    The correct syntax should be:

    - name: ...
      run: ...
    - run: ...
    - run: ...
    

    Reference about workflow syntax