skip to Main Content

I am trying to setup my first GitHub Workflow and I am facing many YAML syntax issues even I am using the official documentation.

I am using the below YAML:

# This is a basic workflow to help you get started with Actions

name: TestWorkflowGithub

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "main" branch
  pull_request:
    branches:
    - 'testbranch/**'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # The type of runner that the job will run on
  runs-on: ubuntu-latest

  # Steps represent a sequence of tasks that will be executed as part of the job
  steps:
    - name: Checkout the code
      uses: actions/checkout@v3

    - name: Install PMD
      run: |
        PMD_VERSION=`cat pmd/pmd-version.txt`
        wget https://github.com/pmd/pmd/releases/download/pmd_releases%2F6.54.0/pmd-bin-6.54.0.zip
        unzip pmd-bin-6.54.0.zip -d ~
        mv ~/pmd-bin-$6.54.0 ~/pmd
        ~/pmd/bin/run.sh pmd --version

    # Run PMD scandd
    - name: Run PMD scan
      run: ~/pmd/bin/run.sh pmd -d force-app -R pmd/ruleset.xml -f text

GitHub is showing me the below error:
You have an error in your yaml syntax on line 14

Note: the line 14 is "runs-on: ubuntu-latest"

Which is the syntax issue in the above YAML file?

2

Answers


  1. You are missing the job identifier:

    jobs:
      foo: # <-- This
        runs-on: ubuntu-latest
    
        steps:
          - name: Checkout the code
            uses: actions/checkout@v3
    
      steps:
    

    You can use actionlint or vscode-yaml to avoid such syntax issues next time 🙂

    Login or Signup to reply.
  2. A good way to quickly pinpoint the syntax issue in your YAML file is to use the new VSCode extension:

    GitHub Actions: Visual Studio Code Extension is now in public beta (Mar. 2023)

    The GitHub Actions extension for VS Code is now in public beta.
    This extension includes rich editing features, such as syntax validation and autocomplete, making workflow authoring and editing faster and easier.
    Developers will also be able to view workflow runs, inspect logs, and trigger re-runs directly from VS Code.

    To get started, visit the VS Code Marketplace or learn more about the extension’s capabilities from the Actions VS Code Extension blog post.

    See what’s next for Actions by visiting our public roadmap.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search