# GitHub Actions & GitLab CI Validator API

> Validate GitHub Actions workflows, action.yml and .gitlab-ci.yml: JSON Schema, needs, ${{ }} expressions, cron, unpinned actions, script injection.

- Endpoint: `GET | POST https://apibox.io.vn/v1/ci-validate`
- Category: Developer utilities
- HTML docs: https://apibox.io.vn/docs/ci-validate/ (Vietnamese: https://apibox.io.vn/vi/docs/ci-validate/)
- Online tool: https://apibox.io.vn/tools/ci-validate/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

Send the YAML (text, file or raw body); the type is detected (or set `type` to `github-workflow`, `github-action` or `gitlab-ci`). Step 1 validates it against the official JSON Schemas (SchemaStore github-workflow / github-action, GitLab ci.json, refreshed weekly) and reports the most specific error per location with the YAML line number. Duplicate keys and YAML syntax errors are caught too.

Step 2 runs semantic and security checks: `needs` pointing to unknown jobs or forming a cycle, `${{ }}` expression syntax (double-quoted strings, unknown functions / contexts) and context availability (e.g. `secrets` in `if`, `matrix` in a job `if`), `steps.<id>` / `needs.<job>` references, empty matrices, cron syntax and frequency, retired runner images (ubuntu-20.04, windows-2019, macos-13…) and dead action versions (upload-artifact v3, cache v2), actions not pinned to a commit SHA (supply-chain risk), `pull_request_target` + checkout of the PR head (pwn request), script injection from issue / PR titles and commit messages, broad `permissions`, deprecated `::set-output`, secrets echoed in logs. For GitLab: unknown stages, `needs` / `dependencies` / `extends` targets, needs on later stages, rules together with only/except, literal secrets in variables.

The response also lists jobs with their dependencies, a Mermaid graph and every action used. Checks are our own (inspired by actionlint’s public rule list). Related: `/v1/dockerfile-lint`, `/v1/k8s-validate`, `/v1/cron`.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `yaml` | body | string | yes |  | Workflow / action.yml / .gitlab-ci.yml content (or file / raw body; max 1 MB). |
| `type` | body|query | string | no | `auto` | `auto`, `github-workflow`, `github-action` or `gitlab-ci`. |
| `schema` | body|query | boolean | no | `true` | Run JSON Schema validation. |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/ci-validate" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"yaml":"name: CI\non: [push, pull_request]\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions/setup-node@v4\n        with:\n          node-version: 22\n      - run: npm ci && npm test\n  deploy:\n    needs: [test, build]\n    if: ${{ github.ref == \"refs/heads/main\" }}\n    runs-on: ubuntu-latest\n    steps:\n      - run: echo \"${{ github.event.head_commit.message }}\"\n"}'
```

## Example response

```json
{
  "valid": false,
  "type": "github-workflow",
  "errors": 3,
  "warnings": 0,
  "info": 3,
  "findings": [
    {
      "rule": "permissions-missing",
      "severity": "info",
      "message": "No top-level \"permissions\": the GITHUB_TOKEN gets the repository default (often read-write); set permissions: contents: read and widen per job",
      "path": "",
      "line": 1
    },
    {
      "rule": "action-not-pinned",
      "severity": "info",
      "message": "actions/checkout@v4 uses the mutable ref \"v4\"; pin actions to a full commit SHA (owner/repo@<40-hex> # v4) — a moved tag runs new code with your secrets (e.g. tj-actions/changed-files, March 2025)",
      "path": "jobs.test.steps.0.uses",
      "line": 7
    },
    "…",
    {
      "rule": "needs-unknown",
      "severity": "error",
      "message": "Job \"deploy\" needs \"build\", which does not exist (jobs: test, deploy)",
      "path": "jobs.deploy.needs",
      "line": 13
    },
    {
      "rule": "expression-syntax",
      "severity": "error",
      "message": "Expression \"github.ref == \"refs/heads/main\"\": string literals use single quotes in GitHub expressions ('text'), not double quotes",
      "path": "jobs.deploy.if",
      "line": 14
    },
    {
      "rule": "script-injection",
      "severity": "error",
      "message": "github.event.head_commit.message is attacker-controlled and is pasted into the script: pass it through env (env: TITLE: ${{ github.event.head_commit.message }}) and use \"$TITLE\"",
      "path": "jobs.deploy.steps.0.run",
      "line": 17
    }
  ],
  "jobs": [
    {
      "id": "test",
      "needs": []
    },
    {
      "id": "deploy",
      "needs": [
        "test",
        "build"
      ]
    }
  ],
  "actions": [
    "actions/checkout@v4",
    "actions/setup-node@v4"
  ],
  "mermaid": "graph LR\n  test[\"test\"]\n  test --> deploy\n  build --> deploy",
  "schema": {
    "name": "github-workflow",
    "source": "https://www.schemastore.org/github-workflow.json",
    "licence": "Apache-2.0 (SchemaStore)",
    "built": "2026-11-16"
  },
  "note": "Kubernetes manifests: /v1/k8s-validate; Dockerfiles: /v1/dockerfile-lint."
}
```

## Use cases

- Validate workflow changes in a pre-commit hook or review bot
- Find unpinned third-party actions across many repositories
- Catch pwn-request and script-injection patterns before merging
- Check .gitlab-ci.yml stages and needs without pushing a pipeline

## FAQ

### Which schemas are used?

SchemaStore github-workflow and github-action (Apache-2.0) and GitLab’s own ci.json (MIT), bundled and refreshed weekly.

### Why warn about tags like @v4?

A tag can be moved to malicious code (as with tj-actions/changed-files in March 2025); a full commit SHA cannot. First-party actions/* are reported as info, third-party ones as warnings.

### Are reusable workflows and includes followed?

No: only the file you send is checked; GitLab references to included jobs are not reported as unknown when the file has an include.
