Search code examples
yamlformattinggithub-actions

GitHub action yaml formatting


I'm trying to make GitHub CI

What's wrong with this formatting? I have such a problem

Invalid workflow file You have an error in your yaml syntax on line 8

screenshot of error

name: Chart project CI
on:
  push:
    branches: [master]
  pull_request:
    branches: [master]
jobs:
  check-links:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [17.x]
    steps:
        uses: actions/checkout@v3
      - name: Starting Node.js  ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}
      - name: install modules
      - run: npm install
      - name: build project
      - run: npm build
      - name: unit test
      - run: npm test


Solution

  • There are some indentation and syntax issue. Please find the correct code below. Here you can find a sample run. Link

    name: Test CI
    on:
      push:
        branches: [main]
      pull_request:
        branches: [main]
    jobs:
      check-links:
        runs-on: ubuntu-latest
        strategy:
          matrix:
            node-version: [17.x]
        steps:
          - uses: actions/checkout@v3
          - name: Starting Node.js  ${{ matrix.node-version }}
            uses: actions/setup-node@v3
            with:
              node-version: ${{ matrix.node-version }}
          - name: install modules
            run: npm install
          - name: build project
            run: npm build
          - name: unit test
            run: npm test