DevOps

GitHub Actions Workflow (JSON) JSON Example

A GitHub Actions CI workflow as a JSON example — triggers, jobs, steps, and a build/test matrix. Copy-ready reference for understanding and generating CI pipeline definitions.

{
  "name": "CI",
  "on": {
    "push": {
      "branches": [
        "main"
      ]
    },
    "pull_request": {}
  },
  "jobs": {
    "test": {
      "runs-on": "ubuntu-latest",
      "steps": [
        {
          "uses": "actions/checkout@v4"
        },
        {
          "uses": "actions/setup-node@v4",
          "with": {
            "node-version": "20"
          }
        },
        {
          "run": "npm ci"
        },
        {
          "run": "npm test"
        }
      ]
    }
  }
}

Field Reference

nameoptionalstringDisplay name of the workflow in the Actions tab
onrequiredobject | stringEvents that trigger the workflow (push, pull_request, schedule, workflow_dispatch)
jobsrequiredobjectMap of job id → job; jobs run in parallel unless 'needs' is set
jobs.<id>.runs-onrequiredstringRunner image, e.g. ubuntu-latest
jobs.<id>.stepsrequiredarray<object>Ordered steps; each is a 'uses' action or a 'run' shell command

Variants

Build matrixRun the same job across multiple versions in parallel.
{
  "jobs": {
    "test": {
      "runs-on": "ubuntu-latest",
      "strategy": {
        "matrix": {
          "node": [
            18,
            20,
            22
          ]
        }
      },
      "steps": [
        {
          "uses": "actions/setup-node@v4",
          "with": {
            "node-version": "${{ matrix.node }}"
          }
        },
        {
          "run": "npm test"
        }
      ]
    }
  }
}

Common Use Cases

  • Understanding the structure of a CI/CD pipeline definition
  • Generating or templating workflows programmatically
  • Converting workflow YAML to JSON for tooling and validation
github actionsci/cdworkflowpipelinedevopsautomation

Validate or format this JSON

One click loads this exact example into the tool — no copy-paste needed. Format it, validate it, explore the tree, or generate TypeScript types instantly.

Frequently Asked Questions

Workflow files are YAML (.github/workflows/*.yml), but because YAML is a superset of JSON, the equivalent JSON shown here is valid too. JSON is useful for generating workflows programmatically or validating them against a schema.

A matrix expands one job into several parallel runs, one per combination of values (e.g. Node 18, 20, 22). It's the standard way to test across multiple language versions, operating systems, or dependency sets without duplicating job definitions.

Related JSON Examples