$devtoolkit.sh/examples/yaml/github-actions

Validate a GitHub Actions Workflow

GitHub Actions workflows are YAML files where formatting errors prevent pipelines from running and error messages can be cryptic. This example shows a CI workflow with lint, test, and build jobs. Validating the YAML syntax before pushing saves time spent waiting for the pipeline to fail. Use the formatter to ensure consistent indentation across the file.

Example
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  lint-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci
      - run: npm run lint
      - run: npm test
[ open in YAML Validator → ]

FAQ

Why is my GitHub Actions workflow not triggering?
Common causes are incorrect branch names in the on trigger, YAML indentation errors that make the file invalid, or the workflow file not being on the default branch.
What is the difference between uses and run in a step?
uses references a reusable action from the marketplace or a repository. run executes a shell command directly on the runner.
How do I cache dependencies in GitHub Actions?
The setup-node action has a built-in cache option. Set cache: npm, pnpm, or yarn and it automatically caches the dependency directory based on your lock file.

Related Examples

/examples/yaml/github-actionsv1.0.0