0

I am trying to learn github actions, so I purchased a course in udemy, but no response from the instructor yet.

I got stuck with the first snippet itself and getting syntax errors.

This is the action snippet I am trying, tried changing different indentations but still getting same error as syntax issue.

name: Shell commands
on: [push]
jobs:
  run-shell-command:
    runs-on: ubuntu-latest
    steps:
      - name: echo a
        string
         run: echo "hello world"
      - name: multiline
        script
          run: |
            node -v
            npm -v

Can anyone please suggest how to fix this.

Sara June
  • 451
  • 1
  • 9
  • 28

2 Answers2

1

YAML format uses indentation to denote scope and requires each entry to be on its own line. It looks like the name key in your example has an incorrect newline character, causing the second part of the name string to appear on the next line. This is incorrect formatting for YAML.

Here is the correct version:

name: Shell commands
on: [push]
jobs:
  run-shell-command:
    runs-on: ubuntu-latest
    steps:
      - name: echo a string
         run: echo "hello world"
      - name: multiline script
          run: |
            node -v
            npm -v
Gasol
  • 111
  • 3
0

try this block:

name: Shell commands
on: [push]
jobs:
  run-shell-command:
    runs-on: ubuntu-latest
    steps:
      - name: echo a
          string
         run: echo "hello world"
      - name: multiline
        script:
          run: |
            node -v
            npm -v

you may use the foloowing webiste to help you validate your yaml code.

https://codebeautify.org/yaml-validator
Zareh Kasparian
  • 753
  • 5
  • 20